home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 10 / BBS In A Box Volume X (AMUG) (January 1994).bin / Files / Prog / U-Z / VideoToolBox.cpt / VideoToolboxSources / TestClut.c < prev    next >
MacBinary  |  1993-03-31  |  16.0 KB  |  [TEXT/KAHL]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
66% dexvert Compact Compressed (Unix) (archive/compact) ext Supported
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, inited, Wed Mar 31 02:08:32 1993, modified Wed Mar 31 02:08:32 1993, creator Think C, type ASCII, 14794 bytes "TestClut.c" , at 0x3a4a 1360 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[KAHL]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0a 54 65 73 74 43 6c | 75 74 2e 63 00 00 00 00 |..TestCl|ut.c....|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4b 41 48 | 4c 01 00 00 00 00 00 00 |.TEXTKAH|L.......|
|00000050| 00 00 00 00 00 39 ca 00 | 00 05 50 a7 de f3 f0 a7 |.....9..|..P.....|
|00000060| de f3 f0 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 0d 3e 00 00 |........|.....>..|
|00000080| 2f 2a 0d 54 65 73 74 43 | 6c 75 74 2e 63 0d 0d 54 |/*.TestC|lut.c..T|
|00000090| 68 69 73 20 69 73 20 75 | 73 65 64 20 62 79 20 54 |his is u|sed by T|
|000000a0| 69 6d 65 56 69 64 65 6f | 3b 20 49 20 63 61 6e 27 |imeVideo|; I can'|
|000000b0| 74 20 74 68 69 6e 6b 20 | 6f 66 20 61 6e 79 20 72 |t think |of any r|
|000000c0| 65 61 73 6f 6e 20 66 6f | 72 20 69 6e 63 6c 75 64 |eason fo|r includ|
|000000d0| 69 6e 67 20 69 74 20 69 | 6e 0d 61 6e 79 20 6f 74 |ing it i|n.any ot|
|000000e0| 68 65 72 20 70 72 6f 67 | 72 61 6d 2e 20 0d 0d 4f |her prog|ram. ..O|
|000000f0| 53 45 72 72 20 54 65 73 | 74 43 6c 75 74 28 46 49 |SErr Tes|tClut(FI|
|00000100| 4c 45 20 2a 6f 5b 32 5d | 2c 47 44 48 61 6e 64 6c |LE *o[2]|,GDHandl|
|00000110| 65 20 64 65 76 69 63 65 | 2c 73 68 6f 72 74 20 66 |e device|,short f|
|00000120| 6c 61 67 73 2c 56 69 64 | 65 6f 43 61 72 64 20 2a |lags,Vid|eoCard *|
|00000130| 63 61 72 64 29 3b 0d 0d | 54 65 73 74 73 20 77 68 |card);..|Tests wh|
|00000140| 65 74 68 65 72 20 74 68 | 65 20 76 69 64 65 6f 20 |ether th|e video |
|00000150| 63 6c 75 74 20 63 61 6e | 20 62 65 20 77 72 69 74 |clut can| be writ|
|00000160| 74 65 6e 20 61 6e 64 20 | 72 65 61 64 20 66 61 69 |ten and |read fai|
|00000170| 74 68 66 75 6c 6c 79 2e | 20 54 68 69 73 20 74 65 |thfully.| This te|
|00000180| 73 74 73 20 66 6f 72 0d | 62 61 64 20 63 6c 75 74 |sts for.|bad clut|
|00000190| 20 6d 65 6d 6f 72 79 2c | 20 61 6e 64 20 77 68 65 | memory,| and whe|
|000001a0| 74 68 65 72 20 74 68 65 | 20 63 6c 75 74 20 69 73 |ther the| clut is|
|000001b0| 20 61 63 74 75 61 6c 6c | 79 20 62 65 69 6e 67 20 | actuall|y being |
|000001c0| 6c 6f 61 64 65 64 20 77 | 69 74 68 20 77 68 61 74 |loaded w|ith what|
|000001d0| 20 77 65 0d 73 65 6e 74 | 2e 20 41 20 73 75 72 70 | we.sent|. A surp|
|000001e0| 72 69 73 69 6e 67 6c 79 | 20 6c 61 72 67 65 20 66 |risingly| large f|
|000001f0| 72 61 63 74 69 6f 6e 20 | 6f 66 20 76 69 64 65 6f |raction |of video|
|00000200| 20 64 72 69 76 65 72 73 | 20 66 61 69 6c 20 74 68 | drivers| fail th|
|00000210| 69 73 20 74 65 73 74 2c | 20 66 6f 72 20 76 61 72 |is test,| for var|
|00000220| 69 6f 75 73 0d 72 65 61 | 73 6f 6e 73 2e 20 54 68 |ious.rea|sons. Th|
|00000230| 65 20 74 65 73 74 20 63 | 6f 6e 73 69 73 74 73 20 |e test c|onsists |
|00000240| 6f 66 20 77 72 69 74 69 | 6e 67 20 72 61 6e 64 6f |of writi|ng rando|
|00000250| 6d 20 6e 75 6d 62 65 72 | 73 20 74 6f 20 61 6c 6c |m number|s to all|
|00000260| 20 74 68 65 20 63 6c 75 | 74 20 65 6e 74 72 69 65 | the clu|t entrie|
|00000270| 73 2c 0d 72 65 61 64 69 | 6e 67 20 74 68 65 6d 20 |s,.readi|ng them |
|00000280| 62 61 63 6b 2c 20 61 6e | 64 20 63 6f 6d 70 61 72 |back, an|d compar|
|00000290| 69 6e 67 2e 0d 0d 54 68 | 65 20 62 69 74 73 20 6f |ing...Th|e bits o|
|000002a0| 66 20 22 66 6c 61 67 73 | 22 20 61 72 65 20 74 65 |f "flags|" are te|
|000002b0| 73 74 65 64 20 69 6e 64 | 65 70 65 6e 64 65 6e 74 |sted ind|ependent|
|000002c0| 6c 79 2e 20 49 66 20 66 | 6c 61 67 73 26 74 65 73 |ly. If f|lags&tes|
|000002d0| 74 43 6c 75 74 51 75 69 | 63 6b 6c 79 46 6c 61 67 |tClutQui|cklyFlag|
|000002e0| 20 74 68 65 6e 0d 53 65 | 74 45 6e 74 72 69 65 73 | then.Se|tEntries|
|000002f0| 51 75 69 63 6b 6c 79 28 | 29 20 77 69 6c 6c 20 62 |Quickly(|) will b|
|00000300| 65 20 74 65 73 74 65 64 | 20 69 6e 73 74 65 61 64 |e tested| instead|
|00000310| 20 6f 66 20 47 44 53 65 | 74 45 6e 74 72 69 65 73 | of GDSe|tEntries|
|00000320| 2f 47 44 44 69 72 65 63 | 74 53 65 74 45 6e 74 72 |/GDDirec|tSetEntr|
|00000330| 69 65 73 2e 0d 49 66 20 | 66 6c 61 67 73 26 74 65 |ies..If |flags&te|
|00000340| 73 74 43 6c 75 74 53 65 | 72 69 61 6c 6c 79 46 6c |stClutSe|riallyFl|
|00000350| 61 67 20 74 68 65 6e 20 | 74 68 65 20 63 6c 75 74 |ag then |the clut|
|00000360| 20 65 6e 74 72 69 65 73 | 20 77 69 6c 6c 20 62 65 | entries| will be|
|00000370| 20 73 65 74 20 69 6e 64 | 69 76 69 64 75 61 6c 6c | set ind|ividuall|
|00000380| 79 2c 0d 63 61 6c 6c 69 | 6e 67 20 47 44 53 65 74 |y,.calli|ng GDSet|
|00000390| 45 6e 74 72 69 65 73 20 | 6f 6e 63 65 20 66 6f 72 |Entries |once for|
|000003a0| 20 65 61 63 68 20 63 6c | 75 74 20 65 6e 74 72 79 | each cl|ut entry|
|000003b0| 2c 20 74 6f 20 63 68 65 | 63 6b 20 74 68 65 20 63 |, to che|ck the c|
|000003c0| 6c 75 74 20 65 6e 74 72 | 79 0d 61 64 64 72 65 73 |lut entr|y.addres|
|000003d0| 73 69 6e 67 2e 20 49 66 | 20 66 6c 61 67 73 26 74 |sing. If| flags&t|
|000003e0| 65 73 74 43 6c 75 74 4c | 69 6e 65 61 72 46 6c 61 |estClutL|inearFla|
|000003f0| 67 20 74 68 65 6e 20 61 | 20 73 69 6d 70 6c 65 20 |g then a| simple |
|00000400| 73 65 71 75 65 6e 63 65 | 2c 20 77 69 6c 6c 20 62 |sequence|, will b|
|00000410| 65 20 6c 6f 61 64 65 64 | 0d 69 6e 74 6f 20 74 68 |e loaded|.into th|
|00000420| 65 20 63 6c 75 74 2c 20 | 69 6e 73 74 65 61 64 20 |e clut, |instead |
|00000430| 6f 66 20 72 61 6e 64 6f | 6d 20 6e 75 6d 62 65 72 |of rando|m number|
|00000440| 73 2c 20 74 6f 20 68 65 | 6c 70 20 66 69 67 75 72 |s, to he|lp figur|
|00000450| 69 6e 67 20 6f 75 74 20 | 73 79 73 74 65 6d 61 74 |ing out |systemat|
|00000460| 69 63 0d 65 72 72 6f 72 | 73 2e 20 54 68 65 20 73 |ic.error|s. The s|
|00000470| 65 71 75 65 6e 63 65 20 | 69 73 20 28 30 2c 30 2c |equence |is (0,0,|
|00000480| 30 29 2c 28 31 2c 30 2c | 30 29 2c 20 28 30 2c 32 |0),(1,0,|0), (0,2|
|00000490| 2c 30 29 2c 28 30 2c 30 | 2c 33 29 2c 28 34 2c 34 |,0),(0,0|,3),(4,4|
|000004a0| 2c 34 29 2c 28 34 2c 30 | 2c 30 29 2c 20 61 6e 64 |,4),(4,0|,0), and|
|000004b0| 20 73 6f 0d 6f 6e 2e 0d | 0d 52 65 74 75 72 6e 65 | so.on..|.Returne|
|000004c0| 64 20 76 61 6c 75 65 20 | 69 73 20 7a 65 72 6f 20 |d value |is zero |
|000004d0| 69 66 20 6f 6b 2c 20 6e | 6f 6e 7a 65 72 6f 20 69 |if ok, n|onzero i|
|000004e0| 66 20 65 72 72 6f 72 20 | 6f 63 63 75 72 72 65 64 |f error |occurred|
|000004f0| 2e 0d 0d 54 65 73 74 43 | 6c 75 74 20 74 72 69 65 |...TestC|lut trie|
|00000500| 73 20 74 6f 20 72 65 63 | 6f 67 6e 69 7a 65 20 63 |s to rec|ognize c|
|00000510| 6f 6d 6d 6f 6e 20 6b 69 | 6e 64 73 20 6f 66 20 64 |ommon ki|nds of d|
|00000520| 72 69 76 65 72 20 65 72 | 72 6f 72 20 61 6e 64 20 |river er|ror and |
|00000530| 72 65 70 6f 72 74 20 74 | 68 65 6d 0d 69 6e 20 61 |report t|hem.in a|
|00000540| 20 73 65 6e 73 69 62 6c | 65 20 77 61 79 2c 20 75 | sensibl|e way, u|
|00000550| 73 69 6e 67 20 74 68 65 | 20 76 61 72 69 6f 75 73 |sing the| various|
|00000560| 20 66 69 65 6c 64 73 20 | 6f 66 20 74 68 65 20 63 | fields |of the c|
|00000570| 61 72 64 2d 3e 64 65 70 | 74 68 5b 6d 5d 2e 63 6c |ard->dep|th[m].cl|
|00000580| 75 74 20 73 74 72 75 63 | 74 75 72 65 2e 0d 45 72 |ut struc|ture..Er|
|00000590| 72 6f 72 73 20 61 63 63 | 75 6d 75 6c 61 74 65 20 |rors acc|umulate |
|000005a0| 69 6e 20 74 68 65 20 63 | 61 72 64 2d 3e 64 65 70 |in the c|ard->dep|
|000005b0| 74 68 5b 6d 5d 2e 63 6c | 75 74 20 73 74 72 75 63 |th[m].cl|ut struc|
|000005c0| 74 75 72 65 2c 20 61 6c | 6c 6f 77 69 6e 67 20 79 |ture, al|lowing y|
|000005d0| 6f 75 20 74 6f 20 6d 61 | 6b 65 0d 6d 75 6c 74 69 |ou to ma|ke.multi|
|000005e0| 70 6c 65 20 63 61 6c 6c | 73 20 74 6f 20 54 65 73 |ple call|s to Tes|
|000005f0| 74 43 6c 75 74 20 61 6e | 64 20 6f 6e 6c 79 20 74 |tClut an|d only t|
|00000600| 68 65 6e 20 73 75 6d 6d | 61 72 69 7a 65 20 74 68 |hen summ|arize th|
|00000610| 65 20 72 65 73 75 6c 74 | 73 2e 20 49 74 20 69 73 |e result|s. It is|
|00000620| 20 69 6d 70 6f 72 74 61 | 6e 74 0d 74 68 61 74 20 | importa|nt.that |
|00000630| 79 6f 75 20 7a 65 72 6f | 20 63 61 72 64 2d 3e 64 |you zero| card->d|
|00000640| 65 70 74 68 5b 6d 5d 2e | 63 6c 75 74 2e 74 65 73 |epth[m].|clut.tes|
|00000650| 74 73 20 61 6e 64 20 63 | 61 72 64 2d 3e 64 65 70 |ts and c|ard->dep|
|00000660| 74 68 5b 6d 5d 2e 63 6c | 75 74 51 75 69 63 6b 6c |th[m].cl|utQuickl|
|00000670| 79 2e 74 65 73 74 73 0d | 62 65 66 6f 72 65 20 79 |y.tests.|before y|
|00000680| 6f 75 72 20 66 69 72 73 | 74 20 63 61 6c 6c 20 74 |our firs|t call t|
|00000690| 6f 20 54 65 73 74 43 6c | 75 74 2c 20 74 6f 20 69 |o TestCl|ut, to i|
|000006a0| 6e 64 75 63 65 20 69 74 | 20 74 6f 20 7a 65 72 6f |nduce it| to zero|
|000006b0| 20 74 68 65 20 72 65 73 | 74 20 6f 66 20 74 68 65 | the res|t of the|
|000006c0| 0d 63 6c 75 74 20 73 74 | 72 75 63 74 75 72 65 73 |.clut st|ructures|
|000006d0| 2e 0d 0d 41 73 73 75 6d | 65 73 20 74 68 61 74 20 |...Assum|es that |
|000006e0| 47 44 65 76 69 63 65 20 | 72 65 63 6f 72 64 20 69 |GDevice |record i|
|000006f0| 73 20 76 61 6c 69 64 2c | 20 69 2e 65 2e 20 74 68 |s valid,| i.e. th|
|00000700| 65 20 75 73 65 72 20 68 | 61 73 20 6e 6f 74 20 63 |e user h|as not c|
|00000710| 61 6c 6c 65 64 20 47 44 | 53 65 74 4d 6f 64 65 28 |alled GD|SetMode(|
|00000720| 29 2e 0d 48 49 53 54 4f | 52 59 3a 0d 33 2f 39 2f |)..HISTO|RY:.3/9/|
|00000730| 39 33 09 64 67 70 09 63 | 6f 64 65 20 65 78 74 72 |93.dgp.c|ode extr|
|00000740| 61 63 74 65 64 20 66 72 | 6f 6d 20 74 68 65 20 64 |acted fr|om the d|
|00000750| 65 6d 6f 20 54 65 73 74 | 43 6c 75 74 73 2e 63 2c |emo Test|Cluts.c,|
|00000760| 20 74 6f 20 63 72 65 61 | 74 65 20 61 20 72 65 75 | to crea|te a reu|
|00000770| 73 61 62 6c 65 0d 09 09 | 73 75 62 72 6f 75 74 69 |sable...|subrouti|
|00000780| 6e 65 2e 0d 33 2f 31 30 | 2f 39 33 09 64 67 70 09 |ne..3/10|/93.dgp.|
|00000790| 4e 6f 20 6c 6f 6e 67 65 | 72 20 61 73 73 75 6d 65 |No longe|r assume|
|000007a0| 20 74 68 61 74 20 47 44 | 65 76 69 63 65 20 72 65 | that GD|evice re|
|000007b0| 63 6f 72 64 20 72 65 66 | 6c 65 63 74 73 20 74 68 |cord ref|lects th|
|000007c0| 65 20 61 63 74 75 61 6c | 20 73 74 61 74 65 20 6f |e actual| state o|
|000007d0| 66 20 74 68 65 0d 09 09 | 64 72 69 76 65 72 2e 0d |f the...|driver..|
|000007e0| 2a 2f 0d 23 69 6e 63 6c | 75 64 65 20 22 56 69 64 |*/.#incl|ude "Vid|
|000007f0| 65 6f 54 6f 6f 6c 62 6f | 78 2e 68 22 0d 23 69 6e |eoToolbo|x.h".#in|
|00000800| 63 6c 75 64 65 20 3c 45 | 72 72 6f 72 73 2e 68 3e |clude <E|rrors.h>|
|00000810| 0d 23 69 6e 63 6c 75 64 | 65 20 22 47 44 49 6e 66 |.#includ|e "GDInf|
|00000820| 6f 2e 68 22 0d 0d 2f 2f | 20 54 68 65 73 65 20 66 |o.h"..//| These f|
|00000830| 75 6e 63 74 69 6f 6e 73 | 20 61 72 65 20 73 6f 6c |unctions| are sol|
|00000840| 65 6c 79 20 66 6f 72 20 | 75 73 65 20 77 69 74 68 |ely for |use with|
|00000850| 69 6e 20 74 68 69 73 20 | 66 69 6c 65 2e 0d 43 6f |in this |file..Co|
|00000860| 6c 6f 72 53 70 65 63 20 | 2a 4d 61 6b 65 43 6c 75 |lorSpec |*MakeClu|
|00000870| 74 54 61 62 6c 65 28 47 | 44 48 61 6e 64 6c 65 20 |tTable(G|DHandle |
|00000880| 64 65 76 69 63 65 2c 73 | 68 6f 72 74 20 66 6c 61 |device,s|hort fla|
|00000890| 67 73 2c 73 68 6f 72 74 | 20 64 61 63 4d 61 73 6b |gs,short| dacMask|
|000008a0| 29 3b 0d 4f 53 45 72 72 | 20 57 72 69 74 65 43 6c |);.OSErr| WriteCl|
|000008b0| 75 74 28 47 44 48 61 6e | 64 6c 65 20 64 65 76 69 |ut(GDHan|dle devi|
|000008c0| 63 65 2c 43 6f 6c 6f 72 | 53 70 65 63 20 74 61 62 |ce,Color|Spec tab|
|000008d0| 6c 65 5b 5d 2c 73 68 6f | 72 74 20 66 6c 61 67 73 |le[],sho|rt flags|
|000008e0| 29 3b 0d 69 6e 74 20 43 | 6f 75 6e 74 43 6c 75 74 |);.int C|ountClut|
|000008f0| 45 72 72 6f 72 73 28 47 | 44 48 61 6e 64 6c 65 20 |Errors(G|DHandle |
|00000900| 64 65 76 69 63 65 2c 43 | 6f 6c 6f 72 53 70 65 63 |device,C|olorSpec|
|00000910| 20 74 61 62 6c 65 5b 5d | 2c 43 6f 6c 6f 72 53 70 | table[]|,ColorSp|
|00000920| 65 63 20 74 61 62 6c 65 | 32 5b 5d 0d 09 2c 73 68 |ec table|2[]..,sh|
|00000930| 6f 72 74 20 66 6c 61 67 | 73 2c 56 69 64 65 6f 43 |ort flag|s,VideoC|
|00000940| 61 72 64 20 2a 63 61 72 | 64 29 3b 0d 76 6f 69 64 |ard *car|d);.void|
|00000950| 20 52 65 70 6f 72 74 43 | 6c 75 74 45 72 72 6f 72 | ReportC|lutError|
|00000960| 73 28 46 49 4c 45 20 2a | 66 69 6c 65 2c 47 44 48 |s(FILE *|file,GDH|
|00000970| 61 6e 64 6c 65 20 64 65 | 76 69 63 65 2c 43 6f 6c |andle de|vice,Col|
|00000980| 6f 72 53 70 65 63 20 74 | 61 62 6c 65 5b 5d 2c 43 |orSpec t|able[],C|
|00000990| 6f 6c 6f 72 53 70 65 63 | 20 74 61 62 6c 65 32 5b |olorSpec| table2[|
|000009a0| 5d 0d 09 2c 73 68 6f 72 | 74 20 66 6c 61 67 73 2c |]..,shor|t flags,|
|000009b0| 56 69 64 65 6f 43 61 72 | 64 20 2a 63 61 72 64 29 |VideoCar|d *card)|
|000009c0| 3b 0d 4f 53 45 72 72 20 | 53 68 6f 77 47 61 6d 6d |;.OSErr |ShowGamm|
|000009d0| 61 54 61 62 6c 65 28 46 | 49 4c 45 20 2a 6f 5b 32 |aTable(F|ILE *o[2|
|000009e0| 5d 2c 47 44 48 61 6e 64 | 6c 65 20 64 65 76 69 63 |],GDHand|le devic|
|000009f0| 65 29 3b 0d 76 6f 69 64 | 20 52 47 42 54 6f 47 72 |e);.void| RGBToGr|
|00000a00| 61 79 28 52 47 42 43 6f | 6c 6f 72 20 2a 72 67 62 |ay(RGBCo|lor *rgb|
|00000a10| 2c 73 68 6f 72 74 20 64 | 61 63 53 69 7a 65 29 3b |,short d|acSize);|
|00000a20| 0d 42 6f 6f 6c 65 61 6e | 20 55 6e 65 71 75 61 6c |.Boolean| Unequal|
|00000a30| 43 6c 75 74 45 6e 74 72 | 79 28 52 47 42 43 6f 6c |ClutEntr|y(RGBCol|
|00000a40| 6f 72 20 2a 61 2c 52 47 | 42 43 6f 6c 6f 72 20 2a |or *a,RG|BColor *|
|00000a50| 62 2c 73 68 6f 72 74 20 | 6d 61 73 6b 29 3b 0d 4f |b,short |mask);.O|
|00000a60| 53 45 72 72 20 56 69 73 | 69 62 6c 65 48 61 73 68 |SErr Vis|ibleHash|
|00000a70| 28 47 44 48 61 6e 64 6c | 65 20 64 65 76 69 63 65 |(GDHandl|e device|
|00000a80| 2c 53 65 74 45 6e 74 72 | 69 65 73 46 75 6e 63 74 |,SetEntr|iesFunct|
|00000a90| 69 6f 6e 20 66 75 6e 63 | 74 69 6f 6e 2c 73 68 6f |ion func|tion,sho|
|00000aa0| 72 74 20 63 6c 75 74 45 | 6e 74 72 69 65 73 0d 09 |rt clutE|ntries..|
|00000ab0| 2c 42 6f 6f 6c 65 61 6e | 20 2a 68 61 73 68 50 74 |,Boolean| *hashPt|
|00000ac0| 72 29 3b 0d 23 64 65 66 | 69 6e 65 20 47 41 4d 4d |r);.#def|ine GAMM|
|00000ad0| 41 5f 54 41 42 4c 45 20 | 30 09 2f 2f 20 45 6e 61 |A_TABLE |0.// Ena|
|00000ae0| 62 6c 65 20 6f 6e 6c 79 | 20 66 6f 72 20 64 65 62 |ble only| for deb|
|00000af0| 75 67 67 69 6e 67 2e 0d | 0d 4f 53 45 72 72 20 54 |ugging..|.OSErr T|
|00000b00| 65 73 74 43 6c 75 74 28 | 46 49 4c 45 20 2a 6f 5b |estClut(|FILE *o[|
|00000b10| 32 5d 2c 47 44 48 61 6e | 64 6c 65 20 64 65 76 69 |2],GDHan|dle devi|
|00000b20| 63 65 2c 73 68 6f 72 74 | 20 66 6c 61 67 73 2c 56 |ce,short| flags,V|
|00000b30| 69 64 65 6f 43 61 72 64 | 20 2a 63 61 72 64 29 0d |ideoCard| *card).|
|00000b40| 7b 0d 09 73 68 6f 72 74 | 20 69 2c 63 6f 6c 6f 72 |{..short| i,color|
|00000b50| 73 2c 65 72 72 6f 72 73 | 3b 0d 09 4f 53 45 72 72 |s,errors|;..OSErr|
|00000b60| 20 65 72 72 6f 72 3b 0d | 09 43 6f 6c 6f 72 53 70 | error;.|.ColorSp|
|00000b70| 65 63 20 73 70 65 63 2c | 2a 74 61 62 6c 65 2c 2a |ec spec,|*table,*|
|00000b80| 74 61 62 6c 65 32 3b 0d | 09 53 65 74 45 6e 74 72 |table2;.|.SetEntr|
|00000b90| 69 65 73 46 75 6e 63 74 | 69 6f 6e 20 66 75 6e 63 |iesFunct|ion func|
|00000ba0| 74 69 6f 6e 3b 0d 09 56 | 69 64 65 6f 43 61 72 64 |tion;..V|ideoCard|
|00000bb0| 43 6c 75 74 54 65 73 74 | 20 2a 63 6c 75 74 3b 0d |ClutTest| *clut;.|
|00000bc0| 09 0d 09 63 6c 75 74 3d | 26 63 61 72 64 2d 3e 64 |...clut=|&card->d|
|00000bd0| 65 70 74 68 5b 63 61 72 | 64 2d 3e 6d 5d 2e 63 6c |epth[car|d->m].cl|
|00000be0| 75 74 3b 0d 09 69 66 28 | 63 6c 75 74 2d 3e 74 65 |ut;..if(|clut->te|
|00000bf0| 73 74 73 3d 3d 30 29 7b | 0d 09 09 63 6c 75 74 2d |sts==0){|...clut-|
|00000c00| 3e 65 72 72 6f 72 73 3d | 30 3b 0d 09 09 63 6c 75 |>errors=|0;...clu|
|00000c10| 74 2d 3e 63 6f 6c 6f 72 | 2e 65 72 72 6f 72 73 3d |t->color|.errors=|
|00000c20| 30 3b 0d 09 09 63 6c 75 | 74 2d 3e 67 72 61 79 2e |0;...clu|t->gray.|
|00000c30| 65 72 72 6f 72 73 3d 30 | 3b 0d 09 09 63 6c 75 74 |errors=0|;...clut|
|00000c40| 2d 3e 63 6f 6c 6f 72 2e | 7a 65 72 6f 53 74 61 72 |->color.|zeroStar|
|00000c50| 74 45 72 72 6f 72 73 3d | 30 3b 0d 09 09 63 6c 75 |tErrors=|0;...clu|
|00000c60| 74 2d 3e 67 72 61 79 2e | 7a 65 72 6f 53 74 61 72 |t->gray.|zeroStar|
|00000c70| 74 45 72 72 6f 72 73 3d | 30 3b 0d 09 7d 0d 09 69 |tErrors=|0;..}..i|
|00000c80| 66 28 63 6c 75 74 2d 3e | 76 69 73 75 61 6c 2e 74 |f(clut->|visual.t|
|00000c90| 65 73 74 73 3d 3d 30 29 | 7b 0d 09 09 63 6c 75 74 |ests==0)|{...clut|
|00000ca0| 2d 3e 76 69 73 75 61 6c | 2e 65 72 72 6f 72 73 3d |->visual|.errors=|
|00000cb0| 30 3b 0d 09 09 63 6c 75 | 74 2d 3e 76 69 73 75 61 |0;...clu|t->visua|
|00000cc0| 6c 2e 7a 65 72 6f 53 74 | 61 72 74 45 72 72 6f 72 |l.zeroSt|artError|
|00000cd0| 73 3d 30 3b 0d 09 7d 0d | 09 63 6c 75 74 3d 26 63 |s=0;..}.|.clut=&c|
|00000ce0| 61 72 64 2d 3e 64 65 70 | 74 68 5b 63 61 72 64 2d |ard->dep|th[card-|
|00000cf0| 3e 6d 5d 2e 63 6c 75 74 | 51 75 69 63 6b 6c 79 3b |>m].clut|Quickly;|
|00000d00| 0d 09 69 66 28 63 6c 75 | 74 2d 3e 74 65 73 74 73 |..if(clu|t->tests|
|00000d10| 3d 3d 30 29 7b 0d 09 09 | 63 6c 75 74 2d 3e 65 72 |==0){...|clut->er|
|00000d20| 72 6f 72 73 3d 30 3b 0d | 09 09 63 6c 75 74 2d 3e |rors=0;.|..clut->|
|00000d30| 63 6f 6c 6f 72 2e 65 72 | 72 6f 72 73 3d 30 3b 0d |color.er|rors=0;.|
|00000d40| 09 09 63 6c 75 74 2d 3e | 67 72 61 79 2e 65 72 72 |..clut->|gray.err|
|00000d50| 6f 72 73 3d 30 3b 0d 09 | 09 63 6c 75 74 2d 3e 63 |ors=0;..|.clut->c|
|00000d60| 6f 6c 6f 72 2e 7a 65 72 | 6f 53 74 61 72 74 45 72 |olor.zer|oStartEr|
|00000d70| 72 6f 72 73 3d 30 3b 0d | 09 09 63 6c 75 74 2d 3e |rors=0;.|..clut->|
|00000d80| 67 72 61 79 2e 7a 65 72 | 6f 53 74 61 72 74 45 72 |gray.zer|oStartEr|
|00000d90| 72 6f 72 73 3d 30 3b 0d | 09 7d 0d 09 69 66 28 63 |rors=0;.|.}..if(c|
|00000da0| 6c 75 74 2d 3e 76 69 73 | 75 61 6c 2e 74 65 73 74 |lut->vis|ual.test|
|00000db0| 73 3d 3d 30 29 7b 0d 09 | 09 63 6c 75 74 2d 3e 76 |s==0){..|.clut->v|
|00000dc0| 69 73 75 61 6c 2e 65 72 | 72 6f 72 73 3d 30 3b 0d |isual.er|rors=0;.|
|00000dd0| 09 09 63 6c 75 74 2d 3e | 76 69 73 75 61 6c 2e 7a |..clut->|visual.z|
|00000de0| 65 72 6f 53 74 61 72 74 | 45 72 72 6f 72 73 3d 30 |eroStart|Errors=0|
|00000df0| 3b 0d 09 7d 0d 09 47 44 | 49 6e 66 6f 28 64 65 76 |;..}..GD|Info(dev|
|00000e00| 69 63 65 2c 63 61 72 64 | 29 3b 0d 09 63 6f 6c 6f |ice,card|);..colo|
|00000e10| 72 73 3d 63 61 72 64 2d | 3e 64 65 70 74 68 5b 63 |rs=card-|>depth[c|
|00000e20| 61 72 64 2d 3e 6d 5d 2e | 63 6f 6c 6f 72 73 3b 0d |ard->m].|colors;.|
|00000e30| 09 23 69 66 20 47 41 4d | 4d 41 5f 54 41 42 4c 45 |.#if GAM|MA_TABLE|
|00000e40| 0d 09 09 53 68 6f 77 47 | 61 6d 6d 61 54 61 62 6c |...ShowG|ammaTabl|
|00000e50| 65 28 6f 2c 64 65 76 69 | 63 65 29 3b 0d 09 23 65 |e(o,devi|ce);..#e|
|00000e60| 6e 64 69 66 0d 09 65 72 | 72 6f 72 3d 47 44 53 61 |ndif..er|ror=GDSa|
|00000e70| 76 65 47 61 6d 6d 61 28 | 64 65 76 69 63 65 29 3b |veGamma(|device);|
|00000e80| 0d 09 65 72 72 6f 72 3d | 47 44 55 6e 63 6f 72 72 |..error=|GDUncorr|
|00000e90| 65 63 74 65 64 47 61 6d | 6d 61 28 64 65 76 69 63 |ectedGam|ma(devic|
|00000ea0| 65 29 3b 0d 09 69 66 28 | 65 72 72 6f 72 29 72 65 |e);..if(|error)re|
|00000eb0| 74 75 72 6e 20 65 72 72 | 6f 72 3b 0d 09 23 69 66 |turn err|or;..#if|
|00000ec0| 20 47 41 4d 4d 41 5f 54 | 41 42 4c 45 0d 09 09 53 | GAMMA_T|ABLE...S|
|00000ed0| 68 6f 77 47 61 6d 6d 61 | 54 61 62 6c 65 28 6f 2c |howGamma|Table(o,|
|00000ee0| 64 65 76 69 63 65 29 3b | 0d 09 23 65 6e 64 69 66 |device);|..#endif|
|00000ef0| 0d 09 0d 09 2f 2f 20 4d | 41 4b 45 20 54 41 42 4c |....// M|AKE TABL|
|00000f00| 45 20 46 4f 52 20 43 4c | 55 54 0d 09 74 61 62 6c |E FOR CL|UT..tabl|
|00000f10| 65 3d 4d 61 6b 65 43 6c | 75 74 54 61 62 6c 65 28 |e=MakeCl|utTable(|
|00000f20| 64 65 76 69 63 65 2c 66 | 6c 61 67 73 2c 63 61 72 |device,f|lags,car|
|00000f30| 64 2d 3e 64 61 63 4d 61 | 73 6b 29 3b 0d 09 69 66 |d->dacMa|sk);..if|
|00000f40| 28 74 61 62 6c 65 3d 3d | 4e 55 4c 4c 29 72 65 74 |(table==|NULL)ret|
|00000f50| 75 72 6e 20 4d 65 6d 45 | 72 72 6f 72 28 29 3b 0d |urn MemE|rror();.|
|00000f60| 09 0d 09 2f 2f 20 57 52 | 49 54 45 20 49 54 20 54 |...// WR|ITE IT T|
|00000f70| 4f 20 43 4c 55 54 0d 09 | 65 72 72 6f 72 3d 57 72 |O CLUT..|error=Wr|
|00000f80| 69 74 65 43 6c 75 74 28 | 64 65 76 69 63 65 2c 74 |iteClut(|device,t|
|00000f90| 61 62 6c 65 2c 66 6c 61 | 67 73 29 3b 0d 09 69 66 |able,fla|gs);..if|
|00000fa0| 28 65 72 72 6f 72 29 72 | 65 74 75 72 6e 20 65 72 |(error)r|eturn er|
|00000fb0| 72 6f 72 3b 0d 09 0d 09 | 2f 2f 20 4d 41 4b 45 20 |ror;....|// MAKE |
|00000fc0| 42 4c 41 4e 4b 20 54 41 | 42 4c 45 0d 09 74 61 62 |BLANK TA|BLE..tab|
|00000fd0| 6c 65 32 3d 28 43 6f 6c | 6f 72 53 70 65 63 20 2a |le2=(Col|orSpec *|
|00000fe0| 29 4e 65 77 50 74 72 28 | 73 69 7a 65 6f 66 28 2a |)NewPtr(|sizeof(*|
|00000ff0| 74 61 62 6c 65 29 2a 63 | 6f 6c 6f 72 73 29 3b 0d |table)*c|olors);.|
|00001000| 09 69 66 28 74 61 62 6c | 65 32 3d 3d 4e 55 4c 4c |.if(tabl|e2==NULL|
|00001010| 29 72 65 74 75 72 6e 20 | 4d 65 6d 45 72 72 6f 72 |)return |MemError|
|00001020| 28 29 3b 0d 09 73 70 65 | 63 2e 76 61 6c 75 65 3d |();..spe|c.value=|
|00001030| 73 70 65 63 2e 72 67 62 | 2e 72 65 64 3d 73 70 65 |spec.rgb|.red=spe|
|00001040| 63 2e 72 67 62 2e 67 72 | 65 65 6e 3d 73 70 65 63 |c.rgb.gr|een=spec|
|00001050| 2e 72 67 62 2e 62 6c 75 | 65 3d 30 3b 0d 09 66 6f |.rgb.blu|e=0;..fo|
|00001060| 72 28 69 3d 30 3b 69 3c | 63 6f 6c 6f 72 73 3b 69 |r(i=0;i<|colors;i|
|00001070| 2b 2b 29 74 61 62 6c 65 | 32 5b 69 5d 3d 73 70 65 |++)table|2[i]=spe|
|00001080| 63 3b 0d 0d 09 2f 2f 20 | 52 45 41 44 20 43 4c 55 |c;...// |READ CLU|
|00001090| 54 20 49 4e 54 4f 20 42 | 4c 41 4e 4b 20 54 41 42 |T INTO B|LANK TAB|
|000010a0| 4c 45 0d 09 65 72 72 6f | 72 3d 47 44 47 65 74 45 |LE..erro|r=GDGetE|
|000010b0| 6e 74 72 69 65 73 28 64 | 65 76 69 63 65 2c 30 2c |ntries(d|evice,0,|
|000010c0| 63 6f 6c 6f 72 73 2d 31 | 2c 74 61 62 6c 65 32 29 |colors-1|,table2)|
|000010d0| 3b 0d 09 69 66 28 21 65 | 72 72 6f 72 29 7b 0d 09 |;..if(!e|rror){..|
|000010e0| 09 2f 2f 20 43 4f 4d 50 | 41 52 45 0d 09 09 65 72 |.// COMP|ARE...er|
|000010f0| 72 6f 72 73 3d 43 6f 75 | 6e 74 43 6c 75 74 45 72 |rors=Cou|ntClutEr|
|00001100| 72 6f 72 73 28 64 65 76 | 69 63 65 2c 74 61 62 6c |rors(dev|ice,tabl|
|00001110| 65 2c 74 61 62 6c 65 32 | 2c 66 6c 61 67 73 2c 63 |e,table2|,flags,c|
|00001120| 61 72 64 29 3b 0d 09 09 | 69 66 28 65 72 72 6f 72 |ard);...|if(error|
|00001130| 73 29 52 65 70 6f 72 74 | 43 6c 75 74 45 72 72 6f |s)Report|ClutErro|
|00001140| 72 73 28 6f 5b 31 5d 2c | 64 65 76 69 63 65 2c 74 |rs(o[1],|device,t|
|00001150| 61 62 6c 65 2c 74 61 62 | 6c 65 32 2c 66 6c 61 67 |able,tab|le2,flag|
|00001160| 73 2c 63 61 72 64 29 3b | 0d 09 09 63 61 72 64 2d |s,card);|...card-|
|00001170| 3e 63 6c 75 74 54 65 73 | 74 3d 31 3b 0d 09 7d 0d |>clutTes|t=1;..}.|
|00001180| 09 09 0d 09 44 69 73 70 | 6f 73 65 50 74 72 28 28 |....Disp|osePtr((|
|00001190| 50 74 72 29 74 61 62 6c | 65 29 3b 0d 09 44 69 73 |Ptr)tabl|e);..Dis|
|000011a0| 70 6f 73 65 50 74 72 28 | 28 50 74 72 29 74 61 62 |posePtr(|(Ptr)tab|
|000011b0| 6c 65 32 29 3b 0d 09 47 | 44 52 65 73 74 6f 72 65 |le2);..G|DRestore|
|000011c0| 47 61 6d 6d 61 28 64 65 | 76 69 63 65 29 3b 0d 09 |Gamma(de|vice);..|
|000011d0| 47 44 52 65 73 74 6f 72 | 65 44 65 76 69 63 65 43 |GDRestor|eDeviceC|
|000011e0| 6c 75 74 28 64 65 76 69 | 63 65 29 3b 0d 0d 2f 2f |lut(devi|ce);..//|
|000011f0| 09 69 66 28 65 72 72 6f | 72 20 7c 7c 20 63 61 72 |.if(erro|r || car|
|00001200| 64 2d 3e 76 69 73 75 61 | 6c 29 72 65 74 75 72 6e |d->visua|l)return|
|00001210| 20 54 65 73 74 43 6c 75 | 74 56 69 73 75 61 6c 6c | TestClu|tVisuall|
|00001220| 79 28 64 65 76 69 63 65 | 2c 66 6c 61 67 73 2c 63 |y(device|,flags,c|
|00001230| 61 72 64 29 3b 0d 09 72 | 65 74 75 72 6e 20 30 3b |ard);..r|eturn 0;|
|00001240| 0d 7d 0d 0d 4f 53 45 72 | 72 20 54 65 73 74 43 6c |.}..OSEr|r TestCl|
|00001250| 75 74 56 69 73 75 61 6c | 6c 79 28 47 44 48 61 6e |utVisual|ly(GDHan|
|00001260| 64 6c 65 20 64 65 76 69 | 63 65 2c 73 68 6f 72 74 |dle devi|ce,short|
|00001270| 20 66 6c 61 67 73 2c 56 | 69 64 65 6f 43 61 72 64 | flags,V|ideoCard|
|00001280| 20 2a 63 61 72 64 29 0d | 7b 0d 09 73 68 6f 72 74 | *card).|{..short|
|00001290| 20 69 2c 65 72 72 6f 72 | 2c 63 6f 6c 6f 72 73 3b | i,error|,colors;|
|000012a0| 0d 09 63 68 61 72 20 62 | 6c 61 6e 6b 4c 69 6e 65 |..char b|lankLine|
|000012b0| 5b 5d 3d 22 5c 72 20 20 | 20 20 20 20 20 20 20 20 |[]="\r | |
|000012c0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000012d0| 20 20 20 20 20 20 20 20 | 20 20 20 20 22 0d 09 09 | | "...|
|000012e0| 22 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |" | |
|000012f0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00001300| 20 20 20 20 20 20 20 20 | 20 20 20 5c 72 22 3b 0d | | \r";.|
|00001310| 09 43 6f 6c 6f 72 53 70 | 65 63 20 2a 74 61 62 6c |.ColorSp|ec *tabl|
|00001320| 65 2c 2a 6e 6f 72 6d 61 | 6c 54 61 62 6c 65 3b 0d |e,*norma|lTable;.|
|00001330| 09 42 6f 6f 6c 65 61 6e | 20 77 65 69 72 64 45 72 |.Boolean| weirdEr|
|00001340| 72 6f 72 2c 6e 6f 72 6d | 61 6c 45 72 72 6f 72 3b |ror,norm|alError;|
|00001350| 0d 09 56 69 64 65 6f 43 | 61 72 64 43 6c 75 74 54 |..VideoC|ardClutT|
|00001360| 65 73 74 20 2a 63 6c 75 | 74 3b 0d 09 0d 09 69 66 |est *clu|t;....if|
|00001370| 28 66 6c 61 67 73 26 74 | 65 73 74 43 6c 75 74 51 |(flags&t|estClutQ|
|00001380| 75 69 63 6b 6c 79 46 6c | 61 67 29 63 6c 75 74 3d |uicklyFl|ag)clut=|
|00001390| 26 63 61 72 64 2d 3e 64 | 65 70 74 68 5b 63 61 72 |&card->d|epth[car|
|000013a0| 64 2d 3e 6d 5d 2e 63 6c | 75 74 51 75 69 63 6b 6c |d->m].cl|utQuickl|
|000013b0| 79 3b 0d 09 65 6c 73 65 | 20 63 6c 75 74 3d 26 63 |y;..else| clut=&c|
|000013c0| 61 72 64 2d 3e 64 65 70 | 74 68 5b 63 61 72 64 2d |ard->dep|th[card-|
|000013d0| 3e 6d 5d 2e 63 6c 75 74 | 3b 0d 09 69 66 28 63 6c |>m].clut|;..if(cl|
|000013e0| 75 74 2d 3e 76 69 73 75 | 61 6c 2e 74 65 73 74 73 |ut->visu|al.tests|
|000013f0| 3d 3d 30 29 7b 0d 09 09 | 63 6c 75 74 2d 3e 76 69 |==0){...|clut->vi|
|00001400| 73 75 61 6c 2e 65 72 72 | 6f 72 73 3d 30 3b 0d 09 |sual.err|ors=0;..|
|00001410| 09 63 6c 75 74 2d 3e 76 | 69 73 75 61 6c 2e 7a 65 |.clut->v|isual.ze|
|00001420| 72 6f 53 74 61 72 74 45 | 72 72 6f 72 73 3d 30 3b |roStartE|rrors=0;|
|00001430| 0d 09 7d 0d 09 63 6f 6c | 6f 72 73 3d 47 44 43 6c |..}..col|ors=GDCl|
|00001440| 75 74 53 69 7a 65 28 64 | 65 76 69 63 65 29 3b 0d |utSize(d|evice);.|
|00001450| 09 6e 6f 72 6d 61 6c 54 | 61 62 6c 65 3d 28 28 2a |.normalT|able=((*|
|00001460| 2a 28 2a 2a 28 2a 2a 64 | 65 76 69 63 65 29 2e 67 |*(**(**d|evice).g|
|00001470| 64 50 4d 61 70 29 2e 70 | 6d 54 61 62 6c 65 29 29 |dPMap).p|mTable))|
|00001480| 2e 63 74 54 61 62 6c 65 | 3b 0d 09 69 66 28 64 65 |.ctTable|;..if(de|
|00001490| 76 69 63 65 3d 3d 47 65 | 74 4d 61 69 6e 44 65 76 |vice==Ge|tMainDev|
|000014a0| 69 63 65 28 29 29 0d 09 | 09 74 61 62 6c 65 3d 4d |ice())..|.table=M|
|000014b0| 61 6b 65 43 6c 75 74 54 | 61 62 6c 65 28 64 65 76 |akeClutT|able(dev|
|000014c0| 69 63 65 2c 74 65 73 74 | 43 6c 75 74 4e 65 67 61 |ice,test|ClutNega|
|000014d0| 74 69 76 65 46 6c 61 67 | 2c 63 61 72 64 2d 3e 64 |tiveFlag|,card->d|
|000014e0| 61 63 4d 61 73 6b 29 3b | 0d 09 65 6c 73 65 20 74 |acMask);|..else t|
|000014f0| 61 62 6c 65 3d 4d 61 6b | 65 43 6c 75 74 54 61 62 |able=Mak|eClutTab|
|00001500| 6c 65 28 64 65 76 69 63 | 65 2c 66 6c 61 67 73 2c |le(devic|e,flags,|
|00001510| 63 61 72 64 2d 3e 64 61 | 63 4d 61 73 6b 29 3b 0d |card->da|cMask);.|
|00001520| 09 69 66 28 74 61 62 6c | 65 3d 3d 4e 55 4c 4c 29 |.if(tabl|e==NULL)|
|00001530| 72 65 74 75 72 6e 20 4d | 65 6d 45 72 72 6f 72 28 |return M|emError(|
|00001540| 29 3b 0d 09 47 44 53 61 | 76 65 47 61 6d 6d 61 28 |);..GDSa|veGamma(|
|00001550| 64 65 76 69 63 65 29 3b | 0d 09 47 44 55 6e 63 6f |device);|..GDUnco|
|00001560| 72 72 65 63 74 65 64 47 | 61 6d 6d 61 28 64 65 76 |rrectedG|amma(dev|
|00001570| 69 63 65 29 3b 0d 09 65 | 72 72 6f 72 3d 57 72 69 |ice);..e|rror=Wri|
|00001580| 74 65 43 6c 75 74 28 64 | 65 76 69 63 65 2c 74 61 |teClut(d|evice,ta|
|00001590| 62 6c 65 2c 66 6c 61 67 | 73 29 3b 0d 09 69 66 28 |ble,flag|s);..if(|
|000015a0| 65 72 72 6f 72 29 7b 0d | 09 09 47 44 52 65 73 74 |error){.|..GDRest|
|000015b0| 6f 72 65 47 61 6d 6d 61 | 28 64 65 76 69 63 65 29 |oreGamma|(device)|
|000015c0| 3b 0d 09 09 47 44 52 65 | 73 74 6f 72 65 44 65 76 |;...GDRe|storeDev|
|000015d0| 69 63 65 43 6c 75 74 28 | 64 65 76 69 63 65 29 3b |iceClut(|device);|
|000015e0| 0d 09 09 72 65 74 75 72 | 6e 20 65 72 72 6f 72 3b |...retur|n error;|
|000015f0| 0d 09 7d 0d 09 70 72 69 | 6e 74 66 28 62 6c 61 6e |..}..pri|ntf(blan|
|00001600| 6b 4c 69 6e 65 29 3b 0d | 09 70 72 69 6e 74 66 28 |kLine);.|.printf(|
|00001610| 22 53 63 72 65 65 6e 20 | 73 68 6f 75 6c 64 20 62 |"Screen |should b|
|00001620| 65 20 77 65 69 72 64 6c | 79 20 63 6f 6c 6f 72 65 |e weirdl|y colore|
|00001630| 64 3b 20 77 61 74 63 68 | 20 66 6f 72 20 73 75 62 |d; watch| for sub|
|00001640| 74 6c 65 20 63 68 61 6e | 67 65 20 61 73 20 79 6f |tle chan|ge as yo|
|00001650| 75 20 68 69 74 20 72 65 | 74 75 72 6e 3a 5c 72 22 |u hit re|turn:\r"|
|00001660| 29 3b 0d 09 77 68 69 6c | 65 28 67 65 74 63 68 61 |);..whil|e(getcha|
|00001670| 72 55 6e 62 75 66 66 65 | 72 65 64 28 29 3d 3d 2d |rUnbuffe|red()==-|
|00001680| 31 29 3b 0d 09 65 72 72 | 6f 72 3d 57 72 69 74 65 |1);..err|or=Write|
|00001690| 43 6c 75 74 28 64 65 76 | 69 63 65 2c 74 61 62 6c |Clut(dev|ice,tabl|
|000016a0| 65 2c 30 29 3b 0d 09 69 | 66 28 65 72 72 6f 72 29 |e,0);..i|f(error)|
|000016b0| 7b 0d 09 09 47 44 52 65 | 73 74 6f 72 65 47 61 6d |{...GDRe|storeGam|
|000016c0| 6d 61 28 64 65 76 69 63 | 65 29 3b 0d 09 09 47 44 |ma(devic|e);...GD|
|000016d0| 52 65 73 74 6f 72 65 44 | 65 76 69 63 65 43 6c 75 |RestoreD|eviceClu|
|000016e0| 74 28 64 65 76 69 63 65 | 29 3b 0d 09 09 72 65 74 |t(device|);...ret|
|000016f0| 75 72 6e 20 65 72 72 6f | 72 3b 0d 09 7d 0d 09 70 |urn erro|r;..}..p|
|00001700| 72 69 6e 74 66 28 62 6c | 61 6e 6b 4c 69 6e 65 29 |rintf(bl|ankLine)|
|00001710| 3b 0d 09 70 72 69 6e 74 | 66 28 22 44 69 64 20 79 |;..print|f("Did y|
|00001720| 6f 75 20 73 65 65 20 61 | 6e 79 20 63 68 61 6e 67 |ou see a|ny chang|
|00001730| 65 20 61 74 20 61 6c 6c | 3f 22 29 3b 0d 09 77 65 |e at all|?");..we|
|00001740| 69 72 64 45 72 72 6f 72 | 3d 59 65 73 4f 72 4e 6f |irdError|=YesOrNo|
|00001750| 28 30 29 3b 0d 09 70 72 | 69 6e 74 66 28 22 5c 72 |(0);..pr|intf("\r|
|00001760| 22 29 3b 0d 09 65 72 72 | 6f 72 3d 57 72 69 74 65 |");..err|or=Write|
|00001770| 43 6c 75 74 28 64 65 76 | 69 63 65 2c 6e 6f 72 6d |Clut(dev|ice,norm|
|00001780| 61 6c 54 61 62 6c 65 2c | 66 6c 61 67 73 29 3b 0d |alTable,|flags);.|
|00001790| 09 70 72 69 6e 74 66 28 | 62 6c 61 6e 6b 4c 69 6e |.printf(|blankLin|
|000017a0| 65 29 3b 0d 09 70 72 69 | 6e 74 66 28 22 53 63 72 |e);..pri|ntf("Scr|
|000017b0| 65 65 6e 20 73 68 6f 75 | 6c 64 20 62 65 20 6e 6f |een shou|ld be no|
|000017c0| 72 6d 61 6c 20 6e 6f 77 | 3b 20 77 61 74 63 68 20 |rmal now|; watch |
|000017d0| 66 6f 72 20 73 75 62 74 | 6c 65 20 63 68 61 6e 67 |for subt|le chang|
|000017e0| 65 20 61 73 20 79 6f 75 | 20 68 69 74 20 72 65 74 |e as you| hit ret|
|000017f0| 75 72 6e 3a 5c 72 22 29 | 3b 0d 09 77 68 69 6c 65 |urn:\r")|;..while|
|00001800| 28 67 65 74 63 68 61 72 | 55 6e 62 75 66 66 65 72 |(getchar|Unbuffer|
|00001810| 65 64 28 29 3d 3d 2d 31 | 29 3b 0d 09 65 72 72 6f |ed()==-1|);..erro|
|00001820| 72 3d 57 72 69 74 65 43 | 6c 75 74 28 64 65 76 69 |r=WriteC|lut(devi|
|00001830| 63 65 2c 6e 6f 72 6d 61 | 6c 54 61 62 6c 65 2c 30 |ce,norma|lTable,0|
|00001840| 29 3b 0d 09 70 72 69 6e | 74 66 28 62 6c 61 6e 6b |);..prin|tf(blank|
|00001850| 4c 69 6e 65 29 3b 0d 09 | 70 72 69 6e 74 66 28 22 |Line);..|printf("|
|00001860| 44 69 64 20 79 6f 75 20 | 73 65 65 20 61 6e 79 20 |Did you |see any |
|00001870| 63 68 61 6e 67 65 20 61 | 74 20 61 6c 6c 3f 22 29 |change a|t all?")|
|00001880| 3b 0d 09 6e 6f 72 6d 61 | 6c 45 72 72 6f 72 3d 59 |;..norma|lError=Y|
|00001890| 65 73 4f 72 4e 6f 28 30 | 29 3b 0d 09 70 72 69 6e |esOrNo(0|);..prin|
|000018a0| 74 66 28 22 5c 72 22 29 | 3b 0d 09 47 44 52 65 73 |tf("\r")|;..GDRes|
|000018b0| 74 6f 72 65 47 61 6d 6d | 61 28 64 65 76 69 63 65 |toreGamm|a(device|
|000018c0| 29 3b 0d 09 47 44 52 65 | 73 74 6f 72 65 44 65 76 |);..GDRe|storeDev|
|000018d0| 69 63 65 43 6c 75 74 28 | 64 65 76 69 63 65 29 3b |iceClut(|device);|
|000018e0| 0d 09 44 69 73 70 6f 73 | 65 50 74 72 28 28 50 74 |..Dispos|ePtr((Pt|
|000018f0| 72 29 74 61 62 6c 65 29 | 3b 0d 09 63 6c 75 74 2d |r)table)|;..clut-|
|00001900| 3e 76 69 73 75 61 6c 2e | 74 65 73 74 73 2b 2b 3b |>visual.|tests++;|
|00001910| 0d 09 63 6c 75 74 2d 3e | 76 69 73 75 61 6c 2e 65 |..clut->|visual.e|
|00001920| 72 72 6f 72 73 2b 3d 28 | 77 65 69 72 64 45 72 72 |rrors+=(|weirdErr|
|00001930| 6f 72 20 7c 7c 20 6e 6f | 72 6d 61 6c 45 72 72 6f |or || no|rmalErro|
|00001940| 72 29 3b 0d 09 69 66 28 | 21 28 66 6c 61 67 73 26 |r);..if(|!(flags&|
|00001950| 74 65 73 74 43 6c 75 74 | 53 65 72 69 61 6c 6c 79 |testClut|Serially|
|00001960| 46 6c 61 67 29 29 63 6c | 75 74 2d 3e 76 69 73 75 |Flag))cl|ut->visu|
|00001970| 61 6c 2e 7a 65 72 6f 53 | 74 61 72 74 45 72 72 6f |al.zeroS|tartErro|
|00001980| 72 73 2b 3d 28 77 65 69 | 72 64 45 72 72 6f 72 20 |rs+=(wei|rdError |
|00001990| 7c 7c 20 6e 6f 72 6d 61 | 6c 45 72 72 6f 72 29 3b ||| norma|lError);|
|000019a0| 0d 09 72 65 74 75 72 6e | 20 30 3b 0d 7d 0d 0d 43 |..return| 0;.}..C|
|000019b0| 6f 6c 6f 72 53 70 65 63 | 20 2a 4d 61 6b 65 43 6c |olorSpec| *MakeCl|
|000019c0| 75 74 54 61 62 6c 65 28 | 47 44 48 61 6e 64 6c 65 |utTable(|GDHandle|
|000019d0| 20 64 65 76 69 63 65 2c | 73 68 6f 72 74 20 66 6c | device,|short fl|
|000019e0| 61 67 73 2c 73 68 6f 72 | 74 20 64 61 63 4d 61 73 |ags,shor|t dacMas|
|000019f0| 6b 29 0d 7b 0d 09 73 68 | 6f 72 74 20 73 68 69 66 |k).{..sh|ort shif|
|00001a00| 74 2c 69 2c 63 6f 6c 6f | 72 73 3b 0d 09 52 47 42 |t,i,colo|rs;..RGB|
|00001a10| 43 6f 6c 6f 72 20 70 75 | 74 3b 0d 09 43 6f 6c 6f |Color pu|t;..Colo|
|00001a20| 72 53 70 65 63 20 2a 74 | 61 62 6c 65 3b 0d 09 0d |rSpec *t|able;...|
|00001a30| 09 63 6f 6c 6f 72 73 3d | 47 44 43 6c 75 74 53 69 |.colors=|GDClutSi|
|00001a40| 7a 65 28 64 65 76 69 63 | 65 29 3b 0d 09 73 68 69 |ze(devic|e);..shi|
|00001a50| 66 74 3d 31 36 2d 4c 6f | 67 32 4c 28 63 6f 6c 6f |ft=16-Lo|g2L(colo|
|00001a60| 72 73 29 3b 0d 09 74 61 | 62 6c 65 3d 28 43 6f 6c |rs);..ta|ble=(Col|
|00001a70| 6f 72 53 70 65 63 20 2a | 29 4e 65 77 50 74 72 28 |orSpec *|)NewPtr(|
|00001a80| 73 69 7a 65 6f 66 28 2a | 74 61 62 6c 65 29 2a 63 |sizeof(*|table)*c|
|00001a90| 6f 6c 6f 72 73 29 3b 0d | 09 69 66 28 74 61 62 6c |olors);.|.if(tabl|
|00001aa0| 65 3d 3d 4e 55 4c 4c 29 | 72 65 74 75 72 6e 20 74 |e==NULL)|return t|
|00001ab0| 61 62 6c 65 3b 0d 09 66 | 6f 72 28 69 3d 30 3b 69 |able;..f|or(i=0;i|
|00001ac0| 3c 63 6f 6c 6f 72 73 3b | 69 2b 2b 29 20 7b 0d 09 |<colors;|i++) {..|
|00001ad0| 09 69 66 28 66 6c 61 67 | 73 26 74 65 73 74 43 6c |.if(flag|s&testCl|
|00001ae0| 75 74 4e 65 67 61 74 69 | 76 65 46 6c 61 67 29 7b |utNegati|veFlag){|
|00001af0| 0d 09 09 09 70 75 74 3d | 28 28 2a 2a 28 2a 2a 28 |....put=|((**(**(|
|00001b00| 2a 2a 64 65 76 69 63 65 | 29 2e 67 64 50 4d 61 70 |**device|).gdPMap|
|00001b10| 29 2e 70 6d 54 61 62 6c | 65 29 29 2e 63 74 54 61 |).pmTabl|e)).ctTa|
|00001b20| 62 6c 65 5b 63 6f 6c 6f | 72 73 2d 31 2d 69 5d 2e |ble[colo|rs-1-i].|
|00001b30| 72 67 62 3b 0d 09 09 7d | 65 6c 73 65 20 69 66 28 |rgb;...}|else if(|
|00001b40| 66 6c 61 67 73 26 74 65 | 73 74 43 6c 75 74 4c 69 |flags&te|stClutLi|
|00001b50| 6e 65 61 72 46 6c 61 67 | 29 7b 0d 09 09 09 2f 2f |nearFlag|){....//|
|00001b60| 20 4c 69 6e 65 61 72 20 | 74 65 73 74 20 70 61 74 | Linear |test pat|
|00001b70| 74 65 72 6e 0d 09 09 09 | 70 75 74 2e 72 65 64 3d |tern....|put.red=|
|00001b80| 70 75 74 2e 67 72 65 65 | 6e 3d 70 75 74 2e 62 6c |put.gree|n=put.bl|
|00001b90| 75 65 3d 30 3b 0d 09 09 | 09 73 77 69 74 63 68 28 |ue=0;...|.switch(|
|00001ba0| 69 25 34 29 7b 0d 09 09 | 09 63 61 73 65 20 30 3a |i%4){...|.case 0:|
|00001bb0| 0d 09 09 09 09 70 75 74 | 2e 72 65 64 3d 70 75 74 |.....put|.red=put|
|00001bc0| 2e 67 72 65 65 6e 3d 70 | 75 74 2e 62 6c 75 65 3d |.green=p|ut.blue=|
|00001bd0| 69 3c 3c 73 68 69 66 74 | 3b 0d 09 09 09 09 62 72 |i<<shift|;.....br|
|00001be0| 65 61 6b 3b 0d 09 09 09 | 63 61 73 65 20 31 3a 0d |eak;....|case 1:.|
|00001bf0| 09 09 09 09 70 75 74 2e | 72 65 64 3d 69 3c 3c 73 |....put.|red=i<<s|
|00001c00| 68 69 66 74 3b 0d 09 09 | 09 09 62 72 65 61 6b 3b |hift;...|..break;|
|00001c10| 0d 09 09 09 63 61 73 65 | 20 32 3a 0d 09 09 09 09 |....case| 2:.....|
|00001c20| 70 75 74 2e 67 72 65 65 | 6e 3d 69 3c 3c 73 68 69 |put.gree|n=i<<shi|
|00001c30| 66 74 3b 0d 09 09 09 09 | 62 72 65 61 6b 3b 0d 09 |ft;.....|break;..|
|00001c40| 09 09 63 61 73 65 20 33 | 3a 0d 09 09 09 09 70 75 |..case 3|:.....pu|
|00001c50| 74 2e 62 6c 75 65 3d 69 | 3c 3c 73 68 69 66 74 3b |t.blue=i|<<shift;|
|00001c60| 0d 09 09 09 09 62 72 65 | 61 6b 3b 0d 09 09 09 7d |.....bre|ak;....}|
|00001c70| 0d 09 09 7d 65 6c 73 65 | 7b 0d 09 09 09 2f 2f 20 |...}else|{....// |
|00001c80| 52 61 6e 64 6f 6d 20 74 | 65 73 74 20 70 61 74 74 |Random t|est patt|
|00001c90| 65 72 6e 0d 09 09 09 70 | 75 74 2e 72 65 64 3d 72 |ern....p|ut.red=r|
|00001ca0| 61 6e 64 55 28 29 3b 0d | 09 09 09 70 75 74 2e 67 |andU();.|...put.g|
|00001cb0| 72 65 65 6e 3d 72 61 6e | 64 55 28 29 3b 0d 09 09 |reen=ran|dU();...|
|00001cc0| 09 70 75 74 2e 62 6c 75 | 65 3d 72 61 6e 64 55 28 |.put.blu|e=randU(|
|00001cd0| 29 3b 0d 09 09 7d 0d 09 | 09 70 75 74 2e 72 65 64 |);...}..|.put.red|
|00001ce0| 26 3d 64 61 63 4d 61 73 | 6b 3b 0d 09 09 70 75 74 |&=dacMas|k;...put|
|00001cf0| 2e 67 72 65 65 6e 26 3d | 64 61 63 4d 61 73 6b 3b |.green&=|dacMask;|
|00001d00| 0d 09 09 70 75 74 2e 62 | 6c 75 65 26 3d 64 61 63 |...put.b|lue&=dac|
|00001d10| 4d 61 73 6b 3b 0d 09 09 | 74 61 62 6c 65 5b 69 5d |Mask;...|table[i]|
|00001d20| 2e 72 67 62 3d 70 75 74 | 3b 0d 09 7d 0d 09 72 65 |.rgb=put|;..}..re|
|00001d30| 74 75 72 6e 20 74 61 62 | 6c 65 3b 0d 7d 0d 0d 42 |turn tab|le;.}..B|
|00001d40| 6f 6f 6c 65 61 6e 20 55 | 6e 65 71 75 61 6c 43 6c |oolean U|nequalCl|
|00001d50| 75 74 45 6e 74 72 79 28 | 52 47 42 43 6f 6c 6f 72 |utEntry(|RGBColor|
|00001d60| 20 2a 61 2c 52 47 42 43 | 6f 6c 6f 72 20 2a 62 2c | *a,RGBC|olor *b,|
|00001d70| 73 68 6f 72 74 20 6d 61 | 73 6b 29 0d 7b 0d 09 72 |short ma|sk).{..r|
|00001d80| 65 74 75 72 6e 20 28 61 | 2d 3e 72 65 64 26 6d 61 |eturn (a|->red&ma|
|00001d90| 73 6b 29 21 3d 28 62 2d | 3e 72 65 64 26 6d 61 73 |sk)!=(b-|>red&mas|
|00001da0| 6b 29 0d 09 09 7c 7c 28 | 61 2d 3e 67 72 65 65 6e |k)...||(|a->green|
|00001db0| 26 6d 61 73 6b 29 21 3d | 28 62 2d 3e 67 72 65 65 |&mask)!=|(b->gree|
|00001dc0| 6e 26 6d 61 73 6b 29 0d | 09 09 7c 7c 28 61 2d 3e |n&mask).|..||(a->|
|00001dd0| 62 6c 75 65 26 6d 61 73 | 6b 29 21 3d 28 62 2d 3e |blue&mas|k)!=(b->|
|00001de0| 62 6c 75 65 26 6d 61 73 | 6b 29 3b 0d 7d 0d 0d 69 |blue&mas|k);.}..i|
|00001df0| 6e 74 20 43 6f 75 6e 74 | 43 6c 75 74 45 72 72 6f |nt Count|ClutErro|
|00001e00| 72 73 28 47 44 48 61 6e | 64 6c 65 20 64 65 76 69 |rs(GDHan|dle devi|
|00001e10| 63 65 2c 43 6f 6c 6f 72 | 53 70 65 63 20 74 61 62 |ce,Color|Spec tab|
|00001e20| 6c 65 5b 5d 2c 43 6f 6c | 6f 72 53 70 65 63 20 74 |le[],Col|orSpec t|
|00001e30| 61 62 6c 65 32 5b 5d 0d | 09 2c 73 68 6f 72 74 20 |able2[].|.,short |
|00001e40| 66 6c 61 67 73 2c 56 69 | 64 65 6f 43 61 72 64 20 |flags,Vi|deoCard |
|00001e50| 2a 63 61 72 64 29 0d 7b | 0d 09 73 68 6f 72 74 20 |*card).{|..short |
|00001e60| 65 72 72 6f 72 73 2c 69 | 2c 6d 2c 63 6f 6c 6f 72 |errors,i|,m,color|
|00001e70| 73 3b 0d 09 73 68 6f 72 | 74 20 63 6f 6c 6f 72 45 |s;..shor|t colorE|
|00001e80| 72 72 6f 72 73 2c 67 72 | 61 79 45 72 72 6f 72 73 |rrors,gr|ayErrors|
|00001e90| 3b 0d 09 52 47 42 43 6f | 6c 6f 72 20 70 75 74 2c |;..RGBCo|lor put,|
|00001ea0| 67 72 61 79 2c 67 6f 74 | 3b 0d 09 56 69 64 65 6f |gray,got|;..Video|
|00001eb0| 43 61 72 64 43 6c 75 74 | 54 65 73 74 20 2a 63 6c |CardClut|Test *cl|
|00001ec0| 75 74 3b 0d 09 0d 09 6d | 3d 63 61 72 64 2d 3e 6d |ut;....m|=card->m|
|00001ed0| 3b 0d 09 63 6f 6c 6f 72 | 73 3d 63 61 72 64 2d 3e |;..color|s=card->|
|00001ee0| 64 65 70 74 68 5b 6d 5d | 2e 63 6f 6c 6f 72 73 3b |depth[m]|.colors;|
|00001ef0| 0d 09 63 6f 6c 6f 72 45 | 72 72 6f 72 73 3d 67 72 |..colorE|rrors=gr|
|00001f00| 61 79 45 72 72 6f 72 73 | 3d 30 3b 0d 09 69 66 28 |ayErrors|=0;..if(|
|00001f10| 66 6c 61 67 73 26 74 65 | 73 74 43 6c 75 74 51 75 |flags&te|stClutQu|
|00001f20| 69 63 6b 6c 79 46 6c 61 | 67 29 20 63 6c 75 74 3d |icklyFla|g) clut=|
|00001f30| 26 63 61 72 64 2d 3e 64 | 65 70 74 68 5b 6d 5d 2e |&card->d|epth[m].|
|00001f40| 63 6c 75 74 51 75 69 63 | 6b 6c 79 3b 0d 09 65 6c |clutQuic|kly;..el|
|00001f50| 73 65 20 63 6c 75 74 3d | 26 63 61 72 64 2d 3e 64 |se clut=|&card->d|
|00001f60| 65 70 74 68 5b 6d 5d 2e | 63 6c 75 74 3b 0d 09 66 |epth[m].|clut;..f|
|00001f70| 6f 72 28 69 3d 30 3b 69 | 3c 63 6f 6c 6f 72 73 3b |or(i=0;i|<colors;|
|00001f80| 69 2b 2b 29 20 7b 0d 09 | 09 67 72 61 79 3d 70 75 |i++) {..|.gray=pu|
|00001f90| 74 3d 74 61 62 6c 65 5b | 69 5d 2e 72 67 62 3b 0d |t=table[|i].rgb;.|
|00001fa0| 09 09 67 6f 74 3d 74 61 | 62 6c 65 32 5b 69 5d 2e |..got=ta|ble2[i].|
|00001fb0| 72 67 62 3b 0d 09 09 52 | 47 42 54 6f 47 72 61 79 |rgb;...R|GBToGray|
|00001fc0| 28 26 67 72 61 79 2c 63 | 61 72 64 2d 3e 64 61 63 |(&gray,c|ard->dac|
|00001fd0| 53 69 7a 65 29 3b 0d 09 | 09 69 66 28 55 6e 65 71 |Size);..|.if(Uneq|
|00001fe0| 75 61 6c 43 6c 75 74 45 | 6e 74 72 79 28 26 70 75 |ualClutE|ntry(&pu|
|00001ff0| 74 2c 26 67 6f 74 2c 63 | 61 72 64 2d 3e 64 61 63 |t,&got,c|ard->dac|
|00002000| 4d 61 73 6b 29 29 63 6f | 6c 6f 72 45 72 72 6f 72 |Mask))co|lorError|
|00002010| 73 2b 2b 3b 0d 09 09 69 | 66 28 55 6e 65 71 75 61 |s++;...i|f(Unequa|
|00002020| 6c 43 6c 75 74 45 6e 74 | 72 79 28 26 67 72 61 79 |lClutEnt|ry(&gray|
|00002030| 2c 26 67 6f 74 2c 63 61 | 72 64 2d 3e 64 61 63 4d |,&got,ca|rd->dacM|
|00002040| 61 73 6b 29 29 67 72 61 | 79 45 72 72 6f 72 73 2b |ask))gra|yErrors+|
|00002050| 2b 3b 0d 09 09 63 6c 75 | 74 2d 3e 74 65 73 74 73 |+;...clu|t->tests|
|00002060| 2b 2b 3b 0d 09 7d 0d 09 | 63 6c 75 74 2d 3e 63 6f |++;..}..|clut->co|
|00002070| 6c 6f 72 2e 65 72 72 6f | 72 73 2b 3d 63 6f 6c 6f |lor.erro|rs+=colo|
|00002080| 72 45 72 72 6f 72 73 3b | 0d 09 63 6c 75 74 2d 3e |rErrors;|..clut->|
|00002090| 67 72 61 79 2e 65 72 72 | 6f 72 73 2b 3d 67 72 61 |gray.err|ors+=gra|
|000020a0| 79 45 72 72 6f 72 73 3b | 0d 09 69 66 28 21 28 66 |yErrors;|..if(!(f|
|000020b0| 6c 61 67 73 26 74 65 73 | 74 43 6c 75 74 53 65 72 |lags&tes|tClutSer|
|000020c0| 69 61 6c 6c 79 46 6c 61 | 67 29 29 7b 0d 09 09 63 |iallyFla|g)){...c|
|000020d0| 6c 75 74 2d 3e 63 6f 6c | 6f 72 2e 7a 65 72 6f 53 |lut->col|or.zeroS|
|000020e0| 74 61 72 74 45 72 72 6f | 72 73 2b 3d 63 6f 6c 6f |tartErro|rs+=colo|
|000020f0| 72 45 72 72 6f 72 73 3b | 0d 09 09 63 6c 75 74 2d |rErrors;|...clut-|
|00002100| 3e 67 72 61 79 2e 7a 65 | 72 6f 53 74 61 72 74 45 |>gray.ze|roStartE|
|00002110| 72 72 6f 72 73 2b 3d 67 | 72 61 79 45 72 72 6f 72 |rrors+=g|rayError|
|00002120| 73 3b 0d 09 7d 0d 09 69 | 66 28 63 61 72 64 2d 3e |s;..}..i|f(card->|
|00002130| 69 73 47 72 61 79 29 65 | 72 72 6f 72 73 3d 67 72 |isGray)e|rrors=gr|
|00002140| 61 79 45 72 72 6f 72 73 | 3b 0d 09 65 6c 73 65 20 |ayErrors|;..else |
|00002150| 65 72 72 6f 72 73 3d 63 | 6f 6c 6f 72 45 72 72 6f |errors=c|olorErro|
|00002160| 72 73 3b 0d 09 63 6c 75 | 74 2d 3e 65 72 72 6f 72 |rs;..clu|t->error|
|00002170| 73 2b 3d 65 72 72 6f 72 | 73 3b 0d 09 72 65 74 75 |s+=error|s;..retu|
|00002180| 72 6e 20 65 72 72 6f 72 | 73 3b 0d 7d 0d 0d 76 6f |rn error|s;.}..vo|
|00002190| 69 64 20 52 65 70 6f 72 | 74 43 6c 75 74 45 72 72 |id Repor|tClutErr|
|000021a0| 6f 72 73 28 46 49 4c 45 | 20 2a 66 69 6c 65 2c 47 |ors(FILE| *file,G|
|000021b0| 44 48 61 6e 64 6c 65 20 | 64 65 76 69 63 65 2c 43 |DHandle |device,C|
|000021c0| 6f 6c 6f 72 53 70 65 63 | 20 74 61 62 6c 65 5b 5d |olorSpec| table[]|
|000021d0| 2c 43 6f 6c 6f 72 53 70 | 65 63 20 74 61 62 6c 65 |,ColorSp|ec table|
|000021e0| 32 5b 5d 0d 09 2c 73 68 | 6f 72 74 20 66 6c 61 67 |2[]..,sh|ort flag|
|000021f0| 73 2c 56 69 64 65 6f 43 | 61 72 64 20 2a 63 61 72 |s,VideoC|ard *car|
|00002200| 64 29 0d 7b 0d 09 73 68 | 6f 72 74 20 65 72 72 6f |d).{..sh|ort erro|
|00002210| 72 73 2c 69 2c 63 6f 6c | 6f 72 73 3d 63 61 72 64 |rs,i,col|ors=card|
|00002220| 2d 3e 64 65 70 74 68 5b | 63 61 72 64 2d 3e 6d 5d |->depth[|card->m]|
|00002230| 2e 63 6f 6c 6f 72 73 3b | 0d 09 73 68 6f 72 74 20 |.colors;|..short |
|00002240| 63 6f 6c 6f 72 45 72 72 | 6f 72 2c 63 6f 6c 6f 72 |colorErr|or,color|
|00002250| 45 72 72 6f 72 73 2c 67 | 72 61 79 45 72 72 6f 72 |Errors,g|rayError|
|00002260| 2c 67 72 61 79 45 72 72 | 6f 72 73 3b 0d 09 52 47 |,grayErr|ors;..RG|
|00002270| 42 43 6f 6c 6f 72 20 70 | 75 74 2c 67 72 61 79 2c |BColor p|ut,gray,|
|00002280| 67 6f 74 3b 0d 09 0d 09 | 2f 2f 20 50 72 69 6e 74 |got;....|// Print|
|00002290| 20 6f 6e 65 2d 6c 69 6e | 65 20 65 72 72 6f 72 20 | one-lin|e error |
|000022a0| 6d 65 73 73 61 67 65 20 | 74 6f 20 66 69 6c 65 0d |message |to file.|
|000022b0| 09 66 70 72 69 6e 74 66 | 28 66 69 6c 65 2c 22 5c |.fprintf|(file,"\|
|000022c0| 6e 22 29 3b 0d 09 69 66 | 28 66 6c 61 67 73 26 74 |n");..if|(flags&t|
|000022d0| 65 73 74 43 6c 75 74 51 | 75 69 63 6b 6c 79 46 6c |estClutQ|uicklyFl|
|000022e0| 61 67 29 66 70 72 69 6e | 74 66 28 66 69 6c 65 2c |ag)fprin|tf(file,|
|000022f0| 22 53 65 74 45 6e 74 72 | 69 65 73 51 75 69 63 6b |"SetEntr|iesQuick|
|00002300| 6c 79 20 21 3d 20 47 44 | 47 65 74 45 6e 74 72 69 |ly != GD|GetEntri|
|00002310| 65 73 22 29 3b 0d 09 65 | 6c 73 65 20 73 77 69 74 |es");..e|lse swit|
|00002320| 63 68 28 63 61 72 64 2d | 3e 67 64 54 79 70 65 29 |ch(card-|>gdType)|
|00002330| 7b 0d 09 63 61 73 65 20 | 66 69 78 65 64 54 79 70 |{..case |fixedTyp|
|00002340| 65 3a 0d 09 09 62 72 65 | 61 6b 3b 0d 09 63 61 73 |e:...bre|ak;..cas|
|00002350| 65 20 63 6c 75 74 54 79 | 70 65 3a 0d 09 09 66 70 |e clutTy|pe:...fp|
|00002360| 72 69 6e 74 66 28 66 69 | 6c 65 2c 22 47 44 53 65 |rintf(fi|le,"GDSe|
|00002370| 74 45 6e 74 72 69 65 73 | 20 21 3d 20 47 44 47 65 |tEntries| != GDGe|
|00002380| 74 45 6e 74 72 69 65 73 | 22 29 3b 0d 09 09 62 72 |tEntries|");...br|
|00002390| 65 61 6b 3b 0d 09 63 61 | 73 65 20 64 69 72 65 63 |eak;..ca|se direc|
|000023a0| 74 54 79 70 65 3a 0d 09 | 09 66 70 72 69 6e 74 66 |tType:..|.fprintf|
|000023b0| 28 66 69 6c 65 2c 22 47 | 44 44 69 72 65 63 74 53 |(file,"G|DDirectS|
|000023c0| 65 74 45 6e 74 72 69 65 | 73 20 21 3d 20 47 44 47 |etEntrie|s != GDG|
|000023d0| 65 74 45 6e 74 72 69 65 | 73 22 29 3b 0d 09 09 62 |etEntrie|s");...b|
|000023e0| 72 65 61 6b 3b 0d 09 7d | 0d 09 69 66 28 66 6c 61 |reak;..}|..if(fla|
|000023f0| 67 73 26 74 65 73 74 43 | 6c 75 74 53 65 72 69 61 |gs&testC|lutSeria|
|00002400| 6c 6c 79 46 6c 61 67 29 | 66 70 72 69 6e 74 66 28 |llyFlag)|fprintf(|
|00002410| 66 69 6c 65 2c 22 20 28 | 4c 6f 61 64 65 64 20 6f |file," (|Loaded o|
|00002420| 6e 65 20 63 6c 75 74 20 | 65 6e 74 72 79 20 61 74 |ne clut |entry at|
|00002430| 20 61 20 74 69 6d 65 2e | 29 5c 6e 22 29 3b 0d 09 | a time.|)\n");..|
|00002440| 65 6c 73 65 20 66 70 72 | 69 6e 74 66 28 66 69 6c |else fpr|intf(fil|
|00002450| 65 2c 22 20 28 4c 6f 61 | 64 65 64 20 77 68 6f 6c |e," (Loa|ded whol|
|00002460| 65 20 63 6c 75 74 20 61 | 74 20 6f 6e 63 65 2e 29 |e clut a|t once.)|
|00002470| 5c 6e 22 29 3b 0d 0d 09 | 2f 2f 20 43 6f 75 6e 74 |\n");...|// Count|
|00002480| 20 65 72 72 6f 72 73 0d | 09 63 6f 6c 6f 72 45 72 | errors.|.colorEr|
|00002490| 72 6f 72 73 3d 67 72 61 | 79 45 72 72 6f 72 73 3d |rors=gra|yErrors=|
|000024a0| 30 3b 0d 09 66 6f 72 28 | 69 3d 30 3b 69 3c 63 6f |0;..for(|i=0;i<co|
|000024b0| 6c 6f 72 73 3b 69 2b 2b | 29 20 7b 0d 09 09 67 72 |lors;i++|) {...gr|
|000024c0| 61 79 3d 70 75 74 3d 74 | 61 62 6c 65 5b 69 5d 2e |ay=put=t|able[i].|
|000024d0| 72 67 62 3b 0d 09 09 67 | 6f 74 3d 74 61 62 6c 65 |rgb;...g|ot=table|
|000024e0| 32 5b 69 5d 2e 72 67 62 | 3b 0d 09 09 52 47 42 54 |2[i].rgb|;...RGBT|
|000024f0| 6f 47 72 61 79 28 26 67 | 72 61 79 2c 63 61 72 64 |oGray(&g|ray,card|
|00002500| 2d 3e 64 61 63 53 69 7a | 65 29 3b 0d 09 09 69 66 |->dacSiz|e);...if|
|00002510| 28 55 6e 65 71 75 61 6c | 43 6c 75 74 45 6e 74 72 |(Unequal|ClutEntr|
|00002520| 79 28 26 70 75 74 2c 26 | 67 6f 74 2c 63 61 72 64 |y(&put,&|got,card|
|00002530| 2d 3e 64 61 63 4d 61 73 | 6b 29 29 63 6f 6c 6f 72 |->dacMas|k))color|
|00002540| 45 72 72 6f 72 73 2b 2b | 3b 0d 09 09 69 66 28 55 |Errors++|;...if(U|
|00002550| 6e 65 71 75 61 6c 43 6c | 75 74 45 6e 74 72 79 28 |nequalCl|utEntry(|
|00002560| 26 67 72 61 79 2c 26 67 | 6f 74 2c 63 61 72 64 2d |&gray,&g|ot,card-|
|00002570| 3e 64 61 63 4d 61 73 6b | 29 29 67 72 61 79 45 72 |>dacMask|))grayEr|
|00002580| 72 6f 72 73 2b 2b 3b 0d | 09 7d 0d 09 69 66 28 63 |rors++;.|.}..if(c|
|00002590| 6f 6c 6f 72 45 72 72 6f | 72 73 3d 3d 30 20 7c 7c |olorErro|rs==0 |||
|000025a0| 20 67 72 61 79 45 72 72 | 6f 72 73 3d 3d 30 29 72 | grayErr|ors==0)r|
|000025b0| 65 74 75 72 6e 3b 0d 09 | 0d 09 2f 2f 20 50 72 69 |eturn;..|..// Pri|
|000025c0| 6e 74 20 65 61 63 68 20 | 65 72 72 6f 72 20 74 6f |nt each |error to|
|000025d0| 20 66 69 6c 65 0d 09 66 | 6f 72 28 69 3d 30 3b 69 | file..f|or(i=0;i|
|000025e0| 3c 63 6f 6c 6f 72 73 3b | 69 2b 2b 29 20 7b 0d 09 |<colors;|i++) {..|
|000025f0| 09 67 72 61 79 3d 70 75 | 74 3d 74 61 62 6c 65 5b |.gray=pu|t=table[|
|00002600| 69 5d 2e 72 67 62 3b 0d | 09 09 67 6f 74 3d 74 61 |i].rgb;.|..got=ta|
|00002610| 62 6c 65 32 5b 69 5d 2e | 72 67 62 3b 0d 09 09 52 |ble2[i].|rgb;...R|
|00002620| 47 42 54 6f 47 72 61 79 | 28 26 67 72 61 79 2c 63 |GBToGray|(&gray,c|
|00002630| 61 72 64 2d 3e 64 61 63 | 53 69 7a 65 29 3b 0d 09 |ard->dac|Size);..|
|00002640| 09 63 6f 6c 6f 72 45 72 | 72 6f 72 3d 55 6e 65 71 |.colorEr|ror=Uneq|
|00002650| 75 61 6c 43 6c 75 74 45 | 6e 74 72 79 28 26 70 75 |ualClutE|ntry(&pu|
|00002660| 74 2c 26 67 6f 74 2c 63 | 61 72 64 2d 3e 64 61 63 |t,&got,c|ard->dac|
|00002670| 4d 61 73 6b 29 3b 0d 09 | 09 67 72 61 79 45 72 72 |Mask);..|.grayErr|
|00002680| 6f 72 3d 55 6e 65 71 75 | 61 6c 43 6c 75 74 45 6e |or=Unequ|alClutEn|
|00002690| 74 72 79 28 26 67 72 61 | 79 2c 26 67 6f 74 2c 63 |try(&gra|y,&got,c|
|000026a0| 61 72 64 2d 3e 64 61 63 | 4d 61 73 6b 29 3b 0d 09 |ard->dac|Mask);..|
|000026b0| 09 69 66 28 21 63 61 72 | 64 2d 3e 69 73 47 72 61 |.if(!car|d->isGra|
|000026c0| 79 20 26 26 20 63 6f 6c | 6f 72 45 72 72 6f 72 20 |y && col|orError |
|000026d0| 7c 7c 20 63 61 72 64 2d | 3e 69 73 47 72 61 79 20 ||| card-|>isGray |
|000026e0| 26 26 20 67 72 61 79 45 | 72 72 6f 72 29 7b 0d 09 |&& grayE|rror){..|
|000026f0| 09 09 66 70 72 69 6e 74 | 66 28 66 69 6c 65 2c 22 |..fprint|f(file,"|
|00002700| 43 6c 75 74 5b 25 33 64 | 5d 20 77 72 6f 74 65 28 |Clut[%3d|] wrote(|
|00002710| 30 78 25 30 34 78 2c 30 | 78 25 30 34 78 2c 30 78 |0x%04x,0|x%04x,0x|
|00002720| 25 30 34 78 29 20 22 0d | 09 09 09 22 28 6c 75 6d |%04x) ".|..."(lum|
|00002730| 69 6e 61 6e 63 65 20 30 | 78 25 30 34 78 29 20 62 |inance 0|x%04x) b|
|00002740| 75 74 20 72 65 61 64 28 | 30 78 25 30 34 78 2c 30 |ut read(|0x%04x,0|
|00002750| 78 25 30 34 78 2c 30 78 | 25 30 34 78 29 5c 6e 22 |x%04x,0x|%04x)\n"|
|00002760| 0d 09 09 09 2c 69 2c 70 | 75 74 2e 72 65 64 2c 70 |....,i,p|ut.red,p|
|00002770| 75 74 2e 67 72 65 65 6e | 2c 70 75 74 2e 62 6c 75 |ut.green|,put.blu|
|00002780| 65 2c 67 72 61 79 2e 72 | 65 64 2c 67 6f 74 2e 72 |e,gray.r|ed,got.r|
|00002790| 65 64 2c 67 6f 74 2e 67 | 72 65 65 6e 2c 67 6f 74 |ed,got.g|reen,got|
|000027a0| 2e 62 6c 75 65 29 3b 0d | 09 09 7d 0d 09 7d 0d 7d |.blue);.|..}..}.}|
|000027b0| 0d 0d 4f 53 45 72 72 20 | 57 72 69 74 65 43 6c 75 |..OSErr |WriteClu|
|000027c0| 74 28 47 44 48 61 6e 64 | 6c 65 20 64 65 76 69 63 |t(GDHand|le devic|
|000027d0| 65 2c 43 6f 6c 6f 72 53 | 70 65 63 20 74 61 62 6c |e,ColorS|pec tabl|
|000027e0| 65 5b 5d 2c 73 68 6f 72 | 74 20 66 6c 61 67 73 29 |e[],shor|t flags)|
|000027f0| 0d 7b 0d 09 73 68 6f 72 | 74 20 69 2c 63 6f 6c 6f |.{..shor|t i,colo|
|00002800| 72 73 3d 47 44 43 6c 75 | 74 53 69 7a 65 28 64 65 |rs=GDClu|tSize(de|
|00002810| 76 69 63 65 29 3b 0d 09 | 63 68 61 72 20 70 72 69 |vice);..|char pri|
|00002820| 6f 72 69 74 79 3d 37 3b | 0d 09 4f 53 45 72 72 20 |ority=7;|..OSErr |
|00002830| 65 72 72 6f 72 3b 0d 09 | 53 65 74 45 6e 74 72 69 |error;..|SetEntri|
|00002840| 65 73 46 75 6e 63 74 69 | 6f 6e 20 66 75 6e 63 74 |esFuncti|on funct|
|00002850| 69 6f 6e 3b 0d 09 09 0d | 09 69 66 28 66 6c 61 67 |ion;....|.if(flag|
|00002860| 73 26 74 65 73 74 43 6c | 75 74 51 75 69 63 6b 6c |s&testCl|utQuickl|
|00002870| 79 46 6c 61 67 29 66 75 | 6e 63 74 69 6f 6e 3d 53 |yFlag)fu|nction=S|
|00002880| 65 74 45 6e 74 72 69 65 | 73 51 75 69 63 6b 6c 79 |etEntrie|sQuickly|
|00002890| 3b 0d 09 65 6c 73 65 20 | 66 75 6e 63 74 69 6f 6e |;..else |function|
|000028a0| 3d 47 44 53 65 74 45 6e | 74 72 69 65 73 42 79 54 |=GDSetEn|triesByT|
|000028b0| 79 70 65 3b 0d 09 69 66 | 28 66 6c 61 67 73 26 74 |ype;..if|(flags&t|
|000028c0| 65 73 74 43 6c 75 74 53 | 65 72 69 61 6c 6c 79 46 |estClutS|eriallyF|
|000028d0| 6c 61 67 29 7b 0d 09 09 | 2f 2f 20 4c 6f 61 64 20 |lag){...|// Load |
|000028e0| 6f 6e 65 20 63 6c 75 74 | 20 65 6e 74 72 79 20 61 |one clut| entry a|
|000028f0| 74 20 61 20 74 69 6d 65 | 0d 09 09 66 6f 72 28 69 |t a time|...for(i|
|00002900| 3d 30 3b 69 3c 63 6f 6c | 6f 72 73 3b 69 2b 2b 29 |=0;i<col|ors;i++)|
|00002910| 7b 0d 09 09 09 53 77 61 | 70 50 72 69 6f 72 69 74 |{....Swa|pPriorit|
|00002920| 79 28 26 70 72 69 6f 72 | 69 74 79 29 3b 09 2f 2f |y(&prior|ity);.//|
|00002930| 20 46 6f 72 63 65 20 64 | 72 69 76 65 72 20 74 6f | Force d|river to|
|00002940| 20 6c 6f 61 64 20 63 6c | 75 74 20 6e 6f 77 2e 0d | load cl|ut now..|
|00002950| 09 09 09 65 72 72 6f 72 | 3d 28 66 75 6e 63 74 69 |...error|=(functi|
|00002960| 6f 6e 29 28 64 65 76 69 | 63 65 2c 69 2c 30 2c 26 |on)(devi|ce,i,0,&|
|00002970| 74 61 62 6c 65 5b 69 5d | 29 3b 0d 09 09 09 53 77 |table[i]|);....Sw|
|00002980| 61 70 50 72 69 6f 72 69 | 74 79 28 26 70 72 69 6f |apPriori|ty(&prio|
|00002990| 72 69 74 79 29 3b 09 2f | 2f 20 46 6f 72 63 65 20 |rity);./|/ Force |
|000029a0| 64 72 69 76 65 72 20 74 | 6f 20 6c 6f 61 64 20 63 |driver t|o load c|
|000029b0| 6c 75 74 20 6e 6f 77 2e | 0d 09 09 09 69 66 28 65 |lut now.|....if(e|
|000029c0| 72 72 6f 72 29 72 65 74 | 75 72 6e 20 65 72 72 6f |rror)ret|urn erro|
|000029d0| 72 3b 0d 09 09 7d 0d 09 | 7d 65 6c 73 65 7b 0d 09 |r;...}..|}else{..|
|000029e0| 09 2f 2f 20 4c 6f 61 64 | 20 77 68 6f 6c 65 20 63 |.// Load| whole c|
|000029f0| 6c 75 74 20 61 74 20 6f | 6e 63 65 0d 09 09 53 77 |lut at o|nce...Sw|
|00002a00| 61 70 50 72 69 6f 72 69 | 74 79 28 26 70 72 69 6f |apPriori|ty(&prio|
|00002a10| 72 69 74 79 29 3b 09 2f | 2f 20 46 6f 72 63 65 20 |rity);./|/ Force |
|00002a20| 64 72 69 76 65 72 20 74 | 6f 20 6c 6f 61 64 20 63 |driver t|o load c|
|00002a30| 6c 75 74 20 6e 6f 77 2e | 0d 09 09 65 72 72 6f 72 |lut now.|...error|
|00002a40| 3d 28 66 75 6e 63 74 69 | 6f 6e 29 28 64 65 76 69 |=(functi|on)(devi|
|00002a50| 63 65 2c 30 2c 63 6f 6c | 6f 72 73 2d 31 2c 74 61 |ce,0,col|ors-1,ta|
|00002a60| 62 6c 65 29 3b 0d 09 09 | 53 77 61 70 50 72 69 6f |ble);...|SwapPrio|
|00002a70| 72 69 74 79 28 26 70 72 | 69 6f 72 69 74 79 29 3b |rity(&pr|iority);|
|00002a80| 09 2f 2f 20 46 6f 72 63 | 65 20 64 72 69 76 65 72 |.// Forc|e driver|
|00002a90| 20 74 6f 20 6c 6f 61 64 | 20 63 6c 75 74 20 6e 6f | to load| clut no|
|00002aa0| 77 2e 0d 09 09 69 66 28 | 65 72 72 6f 72 29 72 65 |w....if(|error)re|
|00002ab0| 74 75 72 6e 20 65 72 72 | 6f 72 3b 0d 09 7d 0d 7d |turn err|or;..}.}|
|00002ac0| 0d 0d 4f 53 45 72 72 20 | 53 68 6f 77 47 61 6d 6d |..OSErr |ShowGamm|
|00002ad0| 61 54 61 62 6c 65 28 46 | 49 4c 45 20 2a 6f 5b 32 |aTable(F|ILE *o[2|
|00002ae0| 5d 2c 47 44 48 61 6e 64 | 6c 65 20 64 65 76 69 63 |],GDHand|le devic|
|00002af0| 65 29 0d 7b 0d 09 4f 53 | 45 72 72 20 65 72 72 6f |e).{..OS|Err erro|
|00002b00| 72 3b 0d 09 75 6e 73 69 | 67 6e 65 64 20 63 68 61 |r;..unsi|gned cha|
|00002b10| 72 20 2a 62 79 74 65 3b | 0d 09 75 6e 73 69 67 6e |r *byte;|..unsign|
|00002b20| 65 64 20 73 68 6f 72 74 | 20 2a 77 6f 72 64 3b 0d |ed short| *word;.|
|00002b30| 09 69 6e 74 20 69 2c 6a | 2c 69 64 65 6e 74 69 74 |.int i,j|,identit|
|00002b40| 79 3b 0d 09 47 61 6d 6d | 61 54 62 6c 20 2a 67 61 |y;..Gamm|aTbl *ga|
|00002b50| 6d 6d 61 3b 0d 09 0d 09 | 69 66 28 28 2a 2a 64 65 |mma;....|if((**de|
|00002b60| 76 69 63 65 29 2e 67 64 | 54 79 70 65 3d 3d 66 69 |vice).gd|Type==fi|
|00002b70| 78 65 64 54 79 70 65 29 | 72 65 74 75 72 6e 20 73 |xedType)|return s|
|00002b80| 74 61 74 75 73 45 72 72 | 3b 0d 09 65 72 72 6f 72 |tatusErr|;..error|
|00002b90| 3d 47 44 47 65 74 47 61 | 6d 6d 61 28 64 65 76 69 |=GDGetGa|mma(devi|
|00002ba0| 63 65 2c 26 67 61 6d 6d | 61 29 3b 0d 09 69 66 28 |ce,&gamm|a);..if(|
|00002bb0| 65 72 72 6f 72 29 7b 0d | 09 09 66 66 70 72 69 6e |error){.|..ffprin|
|00002bc0| 74 66 28 6f 2c 22 47 65 | 74 47 61 6d 6d 61 3a 20 |tf(o,"Ge|tGamma: |
|00002bd0| 47 44 47 65 74 47 61 6d | 6d 61 28 29 20 65 72 72 |GDGetGam|ma() err|
|00002be0| 6f 72 20 25 64 5c 6e 22 | 2c 65 72 72 6f 72 29 3b |or %d\n"|,error);|
|00002bf0| 0d 09 09 69 66 28 65 72 | 72 6f 72 3d 3d 73 74 61 |...if(er|ror==sta|
|00002c00| 74 75 73 45 72 72 29 0d | 09 09 09 66 66 70 72 69 |tusErr).|...ffpri|
|00002c10| 6e 74 66 28 6f 2c 22 54 | 68 65 20 76 69 64 65 6f |ntf(o,"T|he video|
|00002c20| 20 64 72 69 76 65 72 20 | 64 6f 65 73 6e 27 74 20 | driver |doesn't |
|00002c30| 73 75 70 70 6f 72 74 20 | 74 68 69 73 20 63 61 6c |support |this cal|
|00002c40| 6c 2e 5c 6e 22 29 3b 0d | 09 09 72 65 74 75 72 6e |l.\n");.|..return|
|00002c50| 20 65 72 72 6f 72 3b 0d | 09 7d 0d 09 62 79 74 65 | error;.|.}..byte|
|00002c60| 3d 28 75 6e 73 69 67 6e | 65 64 20 63 68 61 72 20 |=(unsign|ed char |
|00002c70| 2a 29 67 61 6d 6d 61 2d | 3e 67 46 6f 72 6d 75 6c |*)gamma-|>gFormul|
|00002c80| 61 44 61 74 61 2b 67 61 | 6d 6d 61 2d 3e 67 46 6f |aData+ga|mma->gFo|
|00002c90| 72 6d 75 6c 61 53 69 7a | 65 3b 0d 09 77 6f 72 64 |rmulaSiz|e;..word|
|00002ca0| 3d 28 75 6e 73 69 67 6e | 65 64 20 73 68 6f 72 74 |=(unsign|ed short|
|00002cb0| 20 2a 29 62 79 74 65 3b | 0d 09 69 64 65 6e 74 69 | *)byte;|..identi|
|00002cc0| 74 79 3d 31 3b 0d 09 69 | 66 28 67 61 6d 6d 61 2d |ty=1;..i|f(gamma-|
|00002cd0| 3e 67 44 61 74 61 57 69 | 64 74 68 3c 3d 38 29 0d |>gDataWi|dth<=8).|
|00002ce0| 09 09 66 6f 72 28 69 3d | 30 3b 69 3c 67 61 6d 6d |..for(i=|0;i<gamm|
|00002cf0| 61 2d 3e 67 44 61 74 61 | 43 6e 74 3b 69 2b 2b 29 |a->gData|Cnt;i++)|
|00002d00| 69 64 65 6e 74 69 74 79 | 20 26 3d 20 28 69 3d 3d |identity| &= (i==|
|00002d10| 62 79 74 65 5b 69 5d 29 | 3b 0d 09 65 6c 73 65 0d |byte[i])|;..else.|
|00002d20| 09 09 66 6f 72 28 69 3d | 30 3b 69 3c 67 61 6d 6d |..for(i=|0;i<gamm|
|00002d30| 61 2d 3e 67 44 61 74 61 | 43 6e 74 3b 69 2b 2b 29 |a->gData|Cnt;i++)|
|00002d40| 69 64 65 6e 74 69 74 79 | 20 26 3d 20 28 69 3d 3d |identity| &= (i==|
|00002d50| 77 6f 72 64 5b 69 5d 29 | 3b 0d 09 69 66 28 69 64 |word[i])|;..if(id|
|00002d60| 65 6e 74 69 74 79 29 7b | 0d 09 09 66 66 70 72 69 |entity){|...ffpri|
|00002d70| 6e 74 66 28 6f 2c 22 47 | 61 6d 6d 61 20 54 61 62 |ntf(o,"G|amma Tab|
|00002d80| 6c 65 3a 20 69 64 65 6e | 74 69 74 79 20 74 72 61 |le: iden|tity tra|
|00002d90| 6e 73 66 6f 72 6d 61 74 | 69 6f 6e 5c 6e 22 29 3b |nsformat|ion\n");|
|00002da0| 0d 09 7d 65 6c 73 65 7b | 0d 09 09 66 66 70 72 69 |..}else{|...ffpri|
|00002db0| 6e 74 66 28 6f 2c 22 47 | 61 6d 6d 61 20 54 61 62 |ntf(o,"G|amma Tab|
|00002dc0| 6c 65 3a 5c 6e 22 29 3b | 0d 09 09 66 66 70 72 69 |le:\n");|...ffpri|
|00002dd0| 6e 74 66 28 6f 2c 22 61 | 74 20 30 78 25 6c 78 2c |ntf(o,"a|t 0x%lx,|
|00002de0| 67 44 61 74 61 57 69 64 | 74 68 20 25 64 2c 67 44 |gDataWid|th %d,gD|
|00002df0| 61 74 61 43 6e 74 20 25 | 64 2c 67 56 65 72 73 69 |ataCnt %|d,gVersi|
|00002e00| 6f 6e 20 25 64 2c 67 54 | 79 70 65 20 25 64 2c 67 |on %d,gT|ype %d,g|
|00002e10| 46 6f 72 6d 75 6c 61 53 | 69 7a 65 20 25 64 2c 67 |FormulaS|ize %d,g|
|00002e20| 43 68 61 6e 43 6e 74 20 | 25 64 5c 6e 22 0d 09 09 |ChanCnt |%d\n"...|
|00002e30| 09 2c 67 61 6d 6d 61 2c | 67 61 6d 6d 61 2d 3e 67 |.,gamma,|gamma->g|
|00002e40| 44 61 74 61 57 69 64 74 | 68 2c 67 61 6d 6d 61 2d |DataWidt|h,gamma-|
|00002e50| 3e 67 44 61 74 61 43 6e | 74 2c 67 61 6d 6d 61 2d |>gDataCn|t,gamma-|
|00002e60| 3e 67 56 65 72 73 69 6f | 6e 2c 67 61 6d 6d 61 2d |>gVersio|n,gamma-|
|00002e70| 3e 67 54 79 70 65 2c 67 | 61 6d 6d 61 2d 3e 67 46 |>gType,g|amma->gF|
|00002e80| 6f 72 6d 75 6c 61 53 69 | 7a 65 2c 67 61 6d 6d 61 |ormulaSi|ze,gamma|
|00002e90| 2d 3e 67 43 68 61 6e 43 | 6e 74 29 3b 0d 09 09 66 |->gChanC|nt);...f|
|00002ea0| 6f 72 28 69 3d 30 3b 69 | 3c 67 61 6d 6d 61 2d 3e |or(i=0;i|<gamma->|
|00002eb0| 67 44 61 74 61 43 6e 74 | 3b 69 2b 3d 36 34 29 20 |gDataCnt|;i+=64) |
|00002ec0| 7b 0d 09 09 09 66 66 70 | 72 69 6e 74 66 28 6f 2c |{....ffp|rintf(o,|
|00002ed0| 22 25 33 64 3a 20 22 2c | 69 29 3b 0d 09 09 09 69 |"%3d: ",|i);....i|
|00002ee0| 66 28 67 61 6d 6d 61 2d | 3e 67 44 61 74 61 57 69 |f(gamma-|>gDataWi|
|00002ef0| 64 74 68 3c 3d 38 29 0d | 09 09 09 09 66 6f 72 28 |dth<=8).|....for(|
|00002f00| 6a 3d 30 3b 6a 3c 31 36 | 3b 6a 2b 2b 29 20 66 66 |j=0;j<16|;j++) ff|
|00002f10| 70 72 69 6e 74 66 28 6f | 2c 22 20 25 33 75 22 2c |printf(o|," %3u",|
|00002f20| 62 79 74 65 5b 69 2b 6a | 5d 29 3b 0d 09 09 09 65 |byte[i+j|]);....e|
|00002f30| 6c 73 65 0d 09 09 09 09 | 66 6f 72 28 6a 3d 30 3b |lse.....|for(j=0;|
|00002f40| 6a 3c 31 36 3b 6a 2b 2b | 29 20 66 66 70 72 69 6e |j<16;j++|) ffprin|
|00002f50| 74 66 28 6f 2c 22 20 25 | 33 75 22 2c 77 6f 72 64 |tf(o," %|3u",word|
|00002f60| 5b 69 2b 6a 5d 29 3b 0d | 09 09 09 66 66 70 72 69 |[i+j]);.|...ffpri|
|00002f70| 6e 74 66 28 6f 2c 22 5c | 6e 22 29 3b 0d 09 09 7d |ntf(o,"\|n");...}|
|00002f80| 0d 09 7d 0d 09 72 65 74 | 75 72 6e 20 30 3b 0d 7d |..}..ret|urn 0;.}|
|00002f90| 0d 2f 2a 0d 57 68 65 6e | 20 79 6f 75 20 73 65 74 |./*.When| you set|
|00002fa0| 20 61 20 76 69 64 65 6f | 20 73 63 72 65 65 6e 20 | a video| screen |
|00002fb0| 74 6f 20 6d 6f 6e 6f 63 | 68 72 6f 6d 65 20 6f 72 |to monoc|hrome or|
|00002fc0| 20 22 67 72 61 79 22 20 | 28 61 73 20 6f 70 70 6f | "gray" |(as oppo|
|00002fd0| 73 65 64 20 74 6f 20 22 | 63 6f 6c 6f 72 22 29 2c |sed to "|color"),|
|00002fe0| 0d 65 2e 67 2e 20 75 73 | 69 6e 67 20 74 68 65 20 |.e.g. us|ing the |
|00002ff0| 43 6f 6e 74 72 6f 6c 20 | 50 61 6e 65 6c 3a 4d 6f |Control |Panel:Mo|
|00003000| 6e 69 74 6f 72 73 2c 20 | 74 68 65 20 72 65 71 75 |nitors, |the requ|
|00003010| 65 73 74 20 69 73 20 70 | 61 73 73 65 64 20 6f 6e |est is p|assed on|
|00003020| 20 74 6f 20 74 68 65 20 | 76 69 64 65 6f 0d 64 72 | to the |video.dr|
|00003030| 69 76 65 72 2e 20 54 68 | 65 20 76 69 64 65 6f 20 |iver. Th|e video |
|00003040| 64 72 69 76 65 72 20 74 | 72 61 6e 73 66 6f 72 6d |driver t|ransform|
|00003050| 73 20 65 61 63 68 20 6f | 66 20 79 6f 75 72 20 72 |s each o|f your r|
|00003060| 67 62 20 74 72 69 70 6c | 65 74 73 20 74 6f 20 61 |gb tripl|ets to a|
|00003070| 0d 6c 75 6d 69 6e 61 6e | 63 65 2d 65 71 75 69 76 |.luminan|ce-equiv|
|00003080| 61 6c 65 6e 74 20 67 72 | 61 79 2c 20 75 73 69 6e |alent gr|ay, usin|
|00003090| 67 20 61 20 66 6f 72 6d | 75 6c 61 20 74 68 61 74 |g a form|ula that|
|000030a0| 20 6d 75 73 74 20 62 65 | 20 76 65 72 79 20 73 69 | must be| very si|
|000030b0| 6d 69 6c 61 72 2c 20 69 | 66 20 6e 6f 74 0d 65 71 |milar, i|f not.eq|
|000030c0| 75 69 76 61 6c 65 6e 74 | 2c 20 74 6f 20 74 68 65 |uivalent|, to the|
|000030d0| 20 63 6f 64 65 20 62 65 | 6c 6f 77 2e 20 54 68 65 | code be|low. The|
|000030e0| 20 72 6f 75 6e 64 69 6e | 67 20 69 73 20 62 61 64 | roundin|g is bad|
|000030f0| 2c 20 65 2e 67 2e 20 61 | 6e 79 20 67 72 61 79 20 |, e.g. a|ny gray |
|00003100| 72 67 62 20 74 72 69 70 | 6c 65 74 0d 28 69 2c 69 |rgb trip|let.(i,i|
|00003110| 2c 69 29 2c 20 6f 74 68 | 65 72 20 74 68 61 6e 20 |,i), oth|er than |
|00003120| 28 30 2c 30 2c 30 29 2c | 20 69 73 20 74 72 61 6e |(0,0,0),| is tran|
|00003130| 73 66 6f 72 6d 65 64 20 | 74 6f 20 28 69 2d 31 2c |sformed |to (i-1,|
|00003140| 69 2d 31 2c 69 2d 31 29 | 2c 20 77 68 69 63 68 20 |i-1,i-1)|, which |
|00003150| 69 73 20 64 61 72 6b 65 | 72 2c 0d 66 61 69 6c 69 |is darke|r,.faili|
|00003160| 6e 67 20 74 6f 20 70 72 | 65 73 65 72 76 65 20 6c |ng to pr|eserve l|
|00003170| 75 6d 69 6e 61 6e 63 65 | 2e 20 48 6f 77 65 76 65 |uminance|. Howeve|
|00003180| 72 2c 20 6d 79 20 67 6f | 61 6c 20 77 61 73 20 74 |r, my go|al was t|
|00003190| 6f 20 72 65 70 6c 69 63 | 61 74 65 20 41 70 70 6c |o replic|ate Appl|
|000031a0| 65 27 73 20 63 72 75 6d | 62 79 0d 74 72 61 6e 73 |e's crum|by.trans|
|000031b0| 66 6f 72 6d 61 74 69 6f | 6e 2c 20 6e 6f 74 20 74 |formatio|n, not t|
|000031c0| 6f 20 69 6d 70 72 6f 76 | 65 20 69 74 2e 20 49 20 |o improv|e it. I |
|000031d0| 70 72 65 73 75 6d 65 20 | 74 68 61 74 20 74 68 65 |presume |that the|
|000031e0| 20 72 65 61 73 6f 6e 20 | 74 68 61 74 20 49 20 68 | reason |that I h|
|000031f0| 61 76 65 20 74 6f 20 74 | 72 69 6d 0d 6d 79 20 6e |ave to t|rim.my n|
|00003200| 75 6d 62 65 72 73 20 64 | 6f 77 6e 20 61 20 74 61 |umbers d|own a ta|
|00003210| 64 20 28 2d 30 2e 30 30 | 30 30 31 29 20 69 73 20 |d (-0.00|001) is |
|00003220| 74 68 61 74 20 49 27 6d | 20 64 6f 69 6e 67 20 74 |that I'm| doing t|
|00003230| 68 69 73 20 77 69 74 68 | 20 38 30 2d 62 69 74 20 |his with| 80-bit |
|00003240| 70 72 65 63 69 73 69 6f | 6e 0d 77 68 65 72 65 61 |precisio|n.wherea|
|00003250| 73 20 74 68 65 20 64 72 | 69 76 65 72 20 75 73 65 |s the dr|iver use|
|00003260| 73 20 74 68 65 20 36 34 | 2d 62 69 74 20 70 72 65 |s the 64|-bit pre|
|00003270| 63 69 73 69 6f 6e 20 6f | 66 20 74 68 65 20 53 41 |cision o|f the SA|
|00003280| 4e 45 20 72 6f 75 74 69 | 6e 65 73 2e 20 50 72 65 |NE routi|nes. Pre|
|00003290| 73 75 6d 61 62 6c 79 20 | 49 0d 63 6f 75 6c 64 20 |sumably |I.could |
|000032a0| 6f 62 74 61 69 6e 20 74 | 68 65 20 73 61 6d 65 20 |obtain t|he same |
|000032b0| 72 65 73 75 6c 74 20 62 | 79 20 63 6f 6d 70 69 6c |result b|y compil|
|000032c0| 69 6e 67 20 74 68 69 73 | 20 73 75 62 72 6f 75 74 |ing this| subrout|
|000032d0| 69 6e 65 20 73 65 70 61 | 72 61 74 65 6c 79 2c 20 |ine sepa|rately, |
|000032e0| 74 6f 20 75 73 65 0d 36 | 34 2d 62 69 74 20 66 6c |to use.6|4-bit fl|
|000032f0| 6f 61 74 69 6e 67 20 70 | 6f 69 6e 74 2c 20 73 69 |oating p|oint, si|
|00003300| 6e 63 65 20 61 6c 6c 20 | 74 68 65 20 61 72 67 75 |nce all |the argu|
|00003310| 6d 65 6e 74 73 20 61 72 | 65 20 69 6e 74 73 2e 0d |ments ar|e ints..|
|00003320| 2a 2f 0d 76 6f 69 64 20 | 52 47 42 54 6f 47 72 61 |*/.void |RGBToGra|
|00003330| 79 28 52 47 42 43 6f 6c | 6f 72 20 2a 72 67 62 2c |y(RGBCol|or *rgb,|
|00003340| 73 68 6f 72 74 20 64 61 | 63 53 69 7a 65 29 0d 2f |short da|cSize)./|
|00003350| 2f 20 45 6d 70 69 72 69 | 63 61 6c 20 66 6f 72 6d |/ Empiri|cal form|
|00003360| 75 6c 61 20 74 6f 20 72 | 65 70 6c 69 63 61 74 65 |ula to r|eplicate|
|00003370| 20 41 70 70 6c 65 27 73 | 20 6c 75 6d 69 6e 61 6e | Apple's| luminan|
|00003380| 63 65 20 6d 61 70 70 69 | 6e 67 2e 0d 7b 0d 09 73 |ce mappi|ng..{..s|
|00003390| 68 6f 72 74 20 69 2c 73 | 68 69 66 74 3b 0d 09 75 |hort i,s|hift;..u|
|000033a0| 6e 73 69 67 6e 65 64 20 | 6c 6f 6e 67 20 6e 3b 0d |nsigned |long n;.|
|000033b0| 09 0d 09 73 68 69 66 74 | 3d 31 36 2d 64 61 63 53 |...shift|=16-dacS|
|000033c0| 69 7a 65 3b 0d 09 69 3d | 28 72 67 62 2d 3e 72 65 |ize;..i=|(rgb->re|
|000033d0| 64 3e 3e 73 68 69 66 74 | 29 2a 28 30 2e 33 30 2d |d>>shift|)*(0.30-|
|000033e0| 30 2e 30 30 30 30 31 29 | 2b 28 72 67 62 2d 3e 67 |0.00001)|+(rgb->g|
|000033f0| 72 65 65 6e 3e 3e 73 68 | 69 66 74 29 2a 28 30 2e |reen>>sh|ift)*(0.|
|00003400| 35 39 2d 30 2e 30 30 30 | 30 31 29 2b 28 72 67 62 |59-0.000|01)+(rgb|
|00003410| 2d 3e 62 6c 75 65 3e 3e | 73 68 69 66 74 29 2a 28 |->blue>>|shift)*(|
|00003420| 30 2e 31 31 29 3b 0d 09 | 6e 3d 30 78 66 66 66 66 |0.11);..|n=0xffff|
|00003430| 66 66 66 66 55 4c 2f 28 | 28 31 3c 3c 64 61 63 53 |ffffUL/(|(1<<dacS|
|00003440| 69 7a 65 29 2d 31 29 3b | 0d 09 72 67 62 2d 3e 72 |ize)-1);|..rgb->r|
|00003450| 65 64 3d 72 67 62 2d 3e | 67 72 65 65 6e 3d 72 67 |ed=rgb->|green=rg|
|00003460| 62 2d 3e 62 6c 75 65 3d | 28 69 2a 6e 29 3e 3e 31 |b->blue=|(i*n)>>1|
|00003470| 36 3b 0d 7d 0d 0d 4f 53 | 45 72 72 20 54 65 73 74 |6;.}..OS|Err Test|
|00003480| 43 6c 75 74 48 61 73 68 | 28 47 44 48 61 6e 64 6c |ClutHash|(GDHandl|
|00003490| 65 20 64 65 76 69 63 65 | 2c 53 65 74 45 6e 74 72 |e device|,SetEntr|
|000034a0| 69 65 73 46 75 6e 63 74 | 69 6f 6e 20 66 75 6e 63 |iesFunct|ion func|
|000034b0| 74 69 6f 6e 2c 56 69 64 | 65 6f 43 61 72 64 43 6c |tion,Vid|eoCardCl|
|000034c0| 75 74 54 65 73 74 20 2a | 63 6c 75 74 29 0d 7b 0d |utTest *|clut).{.|
|000034d0| 09 4f 53 45 72 72 20 65 | 72 72 6f 72 3b 0d 09 0d |.OSErr e|rror;...|
|000034e0| 09 69 66 28 63 6c 75 74 | 2d 3e 68 61 73 68 54 65 |.if(clut|->hashTe|
|000034f0| 73 74 29 7b 0d 09 09 65 | 72 72 6f 72 3d 56 69 73 |st){...e|rror=Vis|
|00003500| 69 62 6c 65 48 61 73 68 | 28 64 65 76 69 63 65 2c |ibleHash|(device,|
|00003510| 66 75 6e 63 74 69 6f 6e | 2c 30 2c 26 63 6c 75 74 |function|,0,&clut|
|00003520| 2d 3e 68 61 73 68 29 3b | 0d 09 7d 65 6c 73 65 20 |->hash);|..}else |
|00003530| 65 72 72 6f 72 3d 30 3b | 0d 09 72 65 74 75 72 6e |error=0;|..return|
|00003540| 20 65 72 72 6f 72 3b 0d | 7d 0d 0d 4f 53 45 72 72 | error;.|}..OSErr|
|00003550| 20 56 69 73 69 62 6c 65 | 48 61 73 68 28 47 44 48 | Visible|Hash(GDH|
|00003560| 61 6e 64 6c 65 20 64 65 | 76 69 63 65 2c 53 65 74 |andle de|vice,Set|
|00003570| 45 6e 74 72 69 65 73 46 | 75 6e 63 74 69 6f 6e 20 |EntriesF|unction |
|00003580| 66 75 6e 63 74 69 6f 6e | 2c 73 68 6f 72 74 20 63 |function|,short c|
|00003590| 6c 75 74 45 6e 74 72 69 | 65 73 0d 09 2c 42 6f 6f |lutEntri|es..,Boo|
|000035a0| 6c 65 61 6e 20 2a 68 61 | 73 68 50 74 72 29 0d 7b |lean *ha|shPtr).{|
|000035b0| 0d 09 4f 53 45 72 72 20 | 65 72 72 6f 72 3b 0d 09 |..OSErr |error;..|
|000035c0| 73 68 6f 72 74 20 6d 6f | 64 65 2c 63 6c 75 74 53 |short mo|de,clutS|
|000035d0| 69 7a 65 2c 69 3b 0d 09 | 42 6f 6f 6c 65 61 6e 20 |ize,i;..|Boolean |
|000035e0| 68 61 73 68 3b 0d 09 6c | 6f 6e 67 20 74 69 63 6b |hash;..l|ong tick|
|000035f0| 3b 0d 09 43 6f 6c 6f 72 | 53 70 65 63 20 2a 74 61 |;..Color|Spec *ta|
|00003600| 62 6c 65 2c 2a 6c 69 6e | 65 61 72 54 61 62 6c 65 |ble,*lin|earTable|
|00003610| 3d 4e 55 4c 4c 3b 0d 09 | 63 68 61 72 20 73 74 72 |=NULL;..|char str|
|00003620| 69 6e 67 5b 31 30 30 5d | 3b 0d 0d 09 63 6c 75 74 |ing[100]|;...clut|
|00003630| 53 69 7a 65 3d 47 44 43 | 6c 75 74 53 69 7a 65 28 |Size=GDC|lutSize(|
|00003640| 64 65 76 69 63 65 29 3b | 0d 09 69 66 28 63 6c 75 |device);|..if(clu|
|00003650| 74 45 6e 74 72 69 65 73 | 3c 30 20 7c 7c 20 63 6c |tEntries|<0 || cl|
|00003660| 75 74 45 6e 74 72 69 65 | 73 3e 63 6c 75 74 53 69 |utEntrie|s>clutSi|
|00003670| 7a 65 29 72 65 74 75 72 | 6e 20 31 3b 0d 09 69 66 |ze)retur|n 1;..if|
|00003680| 28 63 6c 75 74 45 6e 74 | 72 69 65 73 3d 3d 30 29 |(clutEnt|ries==0)|
|00003690| 63 6c 75 74 45 6e 74 72 | 69 65 73 3d 63 6c 75 74 |clutEntr|ies=clut|
|000036a0| 53 69 7a 65 3b 0d 09 65 | 72 72 6f 72 3d 47 44 47 |Size;..e|rror=GDG|
|000036b0| 65 74 4d 6f 64 65 28 64 | 65 76 69 63 65 2c 26 6d |etMode(d|evice,&m|
|000036c0| 6f 64 65 2c 4e 55 4c 4c | 2c 4e 55 4c 4c 29 3b 0d |ode,NULL|,NULL);.|
|000036d0| 09 69 66 28 65 72 72 6f | 72 29 6d 6f 64 65 3d 28 |.if(erro|r)mode=(|
|000036e0| 2a 2a 64 65 76 69 63 65 | 29 2e 67 64 4d 6f 64 65 |**device|).gdMode|
|000036f0| 3b 0d 09 69 66 28 6d 6f | 64 65 3e 65 69 67 68 74 |;..if(mo|de>eight|
|00003700| 42 69 74 4d 6f 64 65 29 | 7b 0d 09 09 69 66 28 66 |BitMode)|{...if(f|
|00003710| 75 6e 63 74 69 6f 6e 3d | 3d 47 44 53 65 74 45 6e |unction=|=GDSetEn|
|00003720| 74 72 69 65 73 29 66 75 | 6e 63 74 69 6f 6e 3d 47 |tries)fu|nction=G|
|00003730| 44 44 69 72 65 63 74 53 | 65 74 45 6e 74 72 69 65 |DDirectS|etEntrie|
|00003740| 73 3b 0d 09 09 74 61 62 | 6c 65 3d 6c 69 6e 65 61 |s;...tab|le=linea|
|00003750| 72 54 61 62 6c 65 3d 28 | 43 6f 6c 6f 72 53 70 65 |rTable=(|ColorSpe|
|00003760| 63 20 2a 29 4e 65 77 50 | 74 72 28 63 6c 75 74 53 |c *)NewP|tr(clutS|
|00003770| 69 7a 65 2a 73 69 7a 65 | 6f 66 28 6c 69 6e 65 61 |ize*size|of(linea|
|00003780| 72 54 61 62 6c 65 5b 30 | 5d 29 29 3b 0d 09 09 69 |rTable[0|]));...i|
|00003790| 66 28 6c 69 6e 65 61 72 | 54 61 62 6c 65 3d 3d 4e |f(linear|Table==N|
|000037a0| 55 4c 4c 29 72 65 74 75 | 72 6e 20 4d 65 6d 45 72 |ULL)retu|rn MemEr|
|000037b0| 72 6f 72 28 29 3b 0d 09 | 09 66 6f 72 28 69 3d 30 |ror();..|.for(i=0|
|000037c0| 3b 69 3c 63 6c 75 74 53 | 69 7a 65 3b 69 2b 2b 29 |;i<clutS|ize;i++)|
|000037d0| 7b 0d 09 09 09 74 61 62 | 6c 65 2d 3e 72 67 62 2e |{....tab|le->rgb.|
|000037e0| 72 65 64 3d 74 61 62 6c | 65 2d 3e 72 67 62 2e 67 |red=tabl|e->rgb.g|
|000037f0| 72 65 65 6e 3d 74 61 62 | 6c 65 2d 3e 72 67 62 2e |reen=tab|le->rgb.|
|00003800| 62 6c 75 65 3d 28 6c 6f | 6e 67 29 30 78 66 66 66 |blue=(lo|ng)0xfff|
|00003810| 66 2a 69 2f 28 63 6c 75 | 74 53 69 7a 65 2d 31 29 |f*i/(clu|tSize-1)|
|00003820| 3b 0d 09 09 09 74 61 62 | 6c 65 2b 2b 3b 0d 09 09 |;....tab|le++;...|
|00003830| 7d 0d 09 7d 65 6c 73 65 | 20 74 61 62 6c 65 3d 28 |}..}else| table=(|
|00003840| 28 2a 2a 28 2a 2a 28 2a | 2a 64 65 76 69 63 65 29 |(**(**(*|*device)|
|00003850| 2e 67 64 50 4d 61 70 29 | 2e 70 6d 54 61 62 6c 65 |.gdPMap)|.pmTable|
|00003860| 29 29 2e 63 74 54 61 62 | 6c 65 3b 0d 09 65 72 72 |)).ctTab|le;..err|
|00003870| 6f 72 3d 28 66 75 6e 63 | 74 69 6f 6e 29 28 64 65 |or=(func|tion)(de|
|00003880| 76 69 63 65 2c 30 2c 63 | 6c 75 74 45 6e 74 72 69 |vice,0,c|lutEntri|
|00003890| 65 73 2d 31 2c 74 61 62 | 6c 65 29 3b 0d 09 69 66 |es-1,tab|le);..if|
|000038a0| 28 21 65 72 72 6f 72 29 | 7b 0d 09 09 70 72 69 6e |(!error)|{...prin|
|000038b0| 74 66 28 22 20 20 20 20 | 20 20 20 20 20 20 20 20 |tf(" | |
|000038c0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000038d0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000038e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000038f0| 20 20 20 20 20 20 20 20 | 5c 72 22 29 3b 0d 09 09 | |\r");...|
|00003900| 70 72 69 6e 74 66 28 22 | 44 6f 20 79 6f 75 20 73 |printf("|Do you s|
|00003910| 65 65 20 61 6e 79 20 68 | 61 73 68 20 6f 6e 20 74 |ee any h|ash on t|
|00003920| 68 65 20 74 65 73 74 20 | 73 63 72 65 65 6e 3f 20 |he test |screen? |
|00003930| 28 4e 6f 29 3a 22 29 3b | 0d 09 09 64 6f 7b 0d 09 |(No):");|...do{..|
|00003940| 09 09 74 69 63 6b 3d 54 | 69 63 6b 43 6f 75 6e 74 |..tick=T|ickCount|
|00003950| 28 29 3b 0d 09 09 09 64 | 6f 7b 0d 09 09 09 09 28 |();....d|o{.....(|
|00003960| 66 75 6e 63 74 69 6f 6e | 29 28 64 65 76 69 63 65 |function|)(device|
|00003970| 2c 30 2c 63 6c 75 74 45 | 6e 74 72 69 65 73 2d 31 |,0,clutE|ntries-1|
|00003980| 2c 74 61 62 6c 65 29 3b | 0d 09 09 09 7d 77 68 69 |,table);|....}whi|
|00003990| 6c 65 28 74 69 63 6b 3d | 3d 54 69 63 6b 43 6f 75 |le(tick=|=TickCou|
|000039a0| 6e 74 28 29 29 3b 0d 09 | 09 7d 77 68 69 6c 65 28 |nt());..|.}while(|
|000039b0| 21 6b 62 68 69 74 28 29 | 29 3b 0d 09 09 68 61 73 |!kbhit()|);...has|
|000039c0| 68 3d 59 65 73 4f 72 4e | 6f 28 30 29 3b 0d 09 09 |h=YesOrN|o(0);...|
|000039d0| 70 72 69 6e 74 66 28 22 | 5c 72 22 29 3b 0d 09 09 |printf("|\r");...|
|000039e0| 69 66 28 6c 69 6e 65 61 | 72 54 61 62 6c 65 21 3d |if(linea|rTable!=|
|000039f0| 4e 55 4c 4c 29 44 69 73 | 70 6f 73 65 50 74 72 28 |NULL)Dis|posePtr(|
|00003a00| 28 50 74 72 29 6c 69 6e | 65 61 72 54 61 62 6c 65 |(Ptr)lin|earTable|
|00003a10| 29 3b 0d 09 09 69 66 28 | 68 61 73 68 50 74 72 21 |);...if(|hashPtr!|
|00003a20| 3d 4e 55 4c 4c 29 2a 68 | 61 73 68 50 74 72 3d 68 |=NULL)*h|ashPtr=h|
|00003a30| 61 73 68 3b 0d 09 7d 0d | 09 72 65 74 75 72 6e 20 |ash;..}.|.return |
|00003a40| 65 72 72 6f 72 3b 0d 7d | 0d 0d 00 00 00 00 00 00 |error;.}|........|
|00003a50| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003a60| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003a70| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003a80| 00 00 01 00 00 00 04 f2 | 00 00 03 f2 00 00 00 5e |........|.......^|
|00003a90| 64 44 65 76 54 79 70 65 | 00 00 01 00 00 00 02 18 |dDevType|........|
|00003aa0| 00 00 01 18 00 00 00 46 | 00 f5 b1 5c 22 e4 00 00 |.......F|...\"...|
|00003ab0| 0a 54 65 73 74 43 6c 75 | 74 2e 63 43 02 00 00 00 |.TestClu|t.cC....|
|00003ac0| 54 45 58 54 4b 41 48 4c | 00 00 00 00 00 00 00 00 |TEXTKAHL|........|
|00003ad0| 00 00 54 45 58 54 4b 41 | 48 4c 00 00 00 00 00 00 |..TEXTKA|HL......|
|00003ae0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003af0| 00 00 a7 e5 d5 d0 00 00 | 00 00 00 00 05 50 11 63 |........|.....P.c|
|00003b00| 61 72 64 2d 3e 6d 6f 6e | 6f 63 68 72 6f 6d 65 20 |ard->mon|ochrome |
|00003b10| 00 16 00 00 25 62 01 0b | 00 ce c8 40 00 00 07 65 |....%b..|...@...e|
|00003b20| 72 72 6f 72 73 20 00 1a | 00 00 25 20 01 09 00 ce |rrors ..|..% ....|
|00003b30| c8 30 00 00 0b 67 72 61 | 79 45 72 72 6f 72 73 20 |.0...gra|yErrors |
|00003b40| 00 1a 00 00 25 48 01 0a | 00 ce c8 20 00 00 0b 63 |....%H..|... ...c|
|00003b50| 6f 6c 6f 72 45 72 72 6f | 72 73 00 14 00 00 0f 8f |olorErro|rs......|
|00003b60| 00 58 00 ce c8 10 00 00 | 05 65 72 72 6f 72 00 18 |.X......|.error..|
|00003b70| 00 00 0f cb 00 59 00 ce | c8 00 00 00 09 61 6e 79 |.....Y..|.....any|
|00003b80| 00 00 00 14 00 00 14 af | ff ff 00 00 00 00 00 00 |........|........|
|00003b90| 22 30 01 1e 00 00 00 00 | 00 00 01 52 00 0b 00 16 |"0......|...R....|
|00003ba0| 00 00 1c bf 00 ee 00 e8 | 0d bc 00 00 07 66 72 61 |........|.....fra|
|00003bb0| 6d 65 73 20 00 16 00 00 | 1c bf 00 ee 00 e8 0d ac |mes ....|........|
|00003bc0| 00 00 07 73 2a 31 30 30 | 30 2e 00 1c 00 00 1c bf |...s*100|0.......|
|00003bd0| 00 ee 00 e8 0d 90 00 00 | 0d 6d 69 73 73 69 6e 67 |........|.missing|
|00003be0| 46 72 61 6d 65 73 00 18 | 00 00 1c bf 00 ee 00 e8 |Frames..|........|
|00003bf0| 0d 80 00 00 09 66 72 61 | 6d 65 52 61 74 65 00 30 |.....fra|meRate.0|
|00003c00| 00 00 1c bf 00 ee 00 e8 | 0d 70 80 00 01 33 03 f1 |........|.p...3..|
|00003c10| 01 dc 04 c6 94 20 00 00 | 00 00 00 00 11 28 2a 63 |..... ..|.....(*c|
|00003c20| 61 72 64 29 2e 64 65 70 | 74 68 5b 33 5d 20 00 1c |ard).dep|th[3] ..|
|00003c30| 00 00 1c bf 00 ee 00 e8 | 0c f0 00 00 0d 28 2a 63 |........|.....(*c|
|00003c40| 61 72 64 29 2e 64 65 70 | 74 68 00 30 00 00 1c bf |ard).dep|th.0....|
|00003c50| 00 ee 00 e8 0c e0 80 00 | 01 07 02 b9 01 dc 03 b7 |........|........|
|00003c60| 94 20 00 00 00 00 00 03 | 00 01 00 02 00 04 00 40 |. ......|.......@|
|00003c70| 00 0a 00 02 05 2a 63 61 | 72 64 00 14 00 00 1c bf |.....*ca|rd......|
|00003c80| 00 ee 00 e8 0c 44 00 00 | 05 63 61 72 64 20 00 30 |.....D..|.card .0|
|00003c90| 00 00 1c bf 00 ee 00 e8 | 0c 34 80 00 01 28 02 d5 |........|.4...(..|
|00003ca0| 01 dc 03 a5 94 20 00 00 | 00 00 00 00 11 28 2a 63 |..... ..|.....(*c|
|00003cb0| 61 72 64 29 2e 64 65 70 | 74 68 5b 30 5d 20 00 16 |ard).dep|th[0] ..|
|00003cc0| 00 00 1c bf 00 ee 00 e8 | 0b 50 00 00 07 63 61 72 |........|.P...car|
|00003cd0| 64 2d 3e 6d 00 1a 00 00 | 1c bf 00 ee 00 e8 0b 20 |d->m....|....... |
|00003ce0| 10 02 0b 63 61 72 64 2d | 3e 6d 6f 64 65 20 00 00 |...card-|>mode ..|
|00003cf0| 00 14 00 00 10 6c 00 78 | 00 00 00 00 00 00 12 ed |.....l.x|........|
|00003d00| 00 8f 00 00 00 00 00 00 | 02 68 00 17 00 14 00 00 |........|.h......|
|00003d10| 0d e5 00 5f 01 01 4e 14 | 00 00 05 65 72 72 6f 72 |..._..N.|...error|
|00003d20| 00 14 00 00 0e 24 00 61 | 01 01 4e 04 00 00 05 65 |.....$.a|..N....e|
|00003d30| 72 72 6f 72 00 16 00 00 | 19 b0 00 c8 01 01 4d e8 |rror....|......M.|
|00003d40| 00 00 07 63 6f 6c 6f 72 | 73 20 00 14 00 00 19 cc |...color|s ......|
|00003d50| 00 c9 01 01 4d d8 00 00 | 05 73 68 69 66 74 00 14 |....M...|.shift..|
|00003d60| 00 00 19 e5 00 ca 01 01 | 4d c8 00 00 05 74 61 62 |........|M....tab|
|00003d70| 6c 65 00 16 00 00 13 b4 | 00 95 01 01 4d b8 00 00 |le......|....M...|
|00003d80| 07 63 6f 6c 6f 72 73 20 | 00 16 00 00 19 b0 00 c8 |.colors |........|
|00003d90| 01 01 4d a8 10 02 07 64 | 61 63 4d 61 73 6b 00 14 |..M....d|acMask..|
|00003da0| 00 00 0e bd 00 68 01 01 | 4d 40 00 00 05 74 61 62 |.....h..|M@...tab|
|00003db0| 6c 65 00 16 00 00 0f 80 | 00 70 01 01 4d 4c 00 00 |le......|.p..ML..|
|00003dc0| 07 74 61 62 6c 65 32 20 | 00 16 00 00 10 a6 00 79 |.table2 |.......y|
|00003dd0| 01 01 4c dc 00 00 07 65 | 72 72 6f 72 73 20 00 30 |..L....e|rrors .0|
|00003de0| 00 00 1e 8c 01 00 01 01 | 4d 18 80 00 00 8c 01 c5 |........|M.......|
|00003df0| 01 8d 02 81 94 20 00 00 | 00 00 00 03 00 0a 00 20 |..... ..|....... |
|00003e00| 00 0b 00 20 00 10 00 02 | 05 2a 63 61 72 64 00 14 |... ....|.*card..|
|00003e10| 00 00 1e 8c 01 00 01 01 | 4c 54 00 00 05 63 61 72 |........|LT...car|
|00003e20| 64 20 00 2c 00 00 1e cd | 01 01 01 01 4b 74 80 00 |d .,....|....Kt..|
|00003e30| 01 16 01 d2 01 88 02 69 | 94 20 00 00 00 00 00 00 |.......i|. ......|
|00003e40| 0d 28 2a 63 6c 75 74 29 | 2e 63 6f 6c 6f 72 00 2c |.(*clut)|.color.,|
|00003e50| 00 00 1e cd 01 01 01 01 | 4b 18 80 00 01 55 01 eb |........|K....U..|
|00003e60| 01 bc 02 66 94 20 00 00 | 00 00 00 00 0d 28 2a 63 |...f. ..|.....(*c|
|00003e70| 6c 75 74 29 2e 67 72 61 | 79 20 00 24 00 00 1e cd |lut).gra|y .$....|
|00003e80| 01 01 01 01 4b cc 80 00 | 00 a0 01 c9 01 6a 02 84 |....K...|.....j..|
|00003e90| 94 20 00 00 00 00 00 00 | 05 2a 63 6c 75 74 00 14 |. ......|.*clut..|
|00003ea0| 00 00 1e cd 01 01 01 01 | 4c 40 00 00 05 63 6c 75 |........|L@...clu|
|00003eb0| 74 20 00 10 00 00 1e ee | 01 02 01 01 4a 70 00 00 |t ......|....Jp..|
|00003ec0| 01 69 00 24 00 00 1f 35 | 01 05 01 01 4a 98 80 00 |.i.$...5|....J...|
|00003ed0| 00 dc 01 d5 01 a6 02 90 | 94 20 00 00 00 00 00 00 |........|. ......|
|00003ee0| 05 67 72 61 79 20 00 1a | 00 00 1f 57 01 06 01 01 |.gray ..|...W....|
|00003ef0| 4a 20 00 00 0b 63 6f 6c | 6f 72 45 72 72 6f 72 73 |J ...col|orErrors|
|00003f00| 00 1a 00 00 1f 95 01 07 | 01 01 4a 18 00 00 0b 67 |........|..J....g|
|00003f10| 72 61 79 45 72 72 6f 72 | 73 20 00 20 00 00 20 09 |rayError|s . .. .|
|00003f20| 01 0b 01 01 49 e8 00 00 | 11 63 6c 75 74 2d 3e 67 |....I...|.clut->g|
|00003f30| 72 61 79 2e 65 72 72 6f | 72 73 00 22 00 00 1f e7 |ray.erro|rs."....|
|00003f40| 01 0a 01 01 4a 1c 00 00 | 13 63 6c 75 74 2d 3e 63 |....J...|.clut->c|
|00003f50| 6f 6c 6f 72 2e 65 72 72 | 6f 72 73 20 00 16 00 00 |olor.err|ors ....|
|00003f60| 20 a6 01 10 01 01 49 ac | 00 00 07 65 72 72 6f 72 | .....I.|...error|
|00003f70| 73 20 00 00 01 00 00 00 | 04 f2 00 00 03 f2 00 00 |s ......|........|
|00003f80| 00 5e 01 08 2b a8 1a d0 | 00 00 00 1c 00 5e 00 01 |.^..+...|.....^..|
|00003f90| 42 4b 50 54 00 01 00 12 | 44 54 56 55 00 01 00 2a |BKPT....|DTVU...*|
|00003fa0| 34 1c ff ff 00 00 00 00 | 00 00 00 00 39 8b ff ff |4.......|....9...|
|00003fb0| 00 00 01 6e 00 00 00 00 | 62 7e ff ff 00 00 00 18 |...n....|b~......|
|00003fc0| 00 00 00 00 36 41 ff ff | 00 00 01 86 00 00 00 00 |....6A..|........|
|00003fd0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003fe0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00003ff0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+